Lesson 3 of 15
Basic Types
Basic Types
OCaml has several built-in types:
| Type | Example |
|---|---|
int | 42, -7, 0 |
float | 3.14, 1.0 |
string | "hello" |
bool | true, false |
char | 'a', 'Z' |
unit | () |
Type Conversions
OCaml does not implicitly convert types. You must be explicit:
let n = 42
let s = string_of_int n (* "42" *)
let f = float_of_int n (* 42.0 *)
let m = int_of_string "100" (* 100 *)
Boolean Operations
let a = true && false (* false *)
let b = true || false (* true *)
let c = not true (* false *)
Your Task
Convert the integer 255 to a string and print it concatenated with " is max byte".
JS Transpiler loading...
Loading...
Click "Run" to execute your code.