Lesson 3 of 15

Basic Types

Basic Types

OCaml has several built-in types:

TypeExample
int42, -7, 0
float3.14, 1.0
string"hello"
booltrue, 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.