Lesson 2 of 15

Let Bindings

Let Bindings

In OCaml, you bind values with let:

let x = 42
let name = "Alice"

By default, bindings are immutable — you cannot reassign them.

Printing Values

Use print_endline for strings, print_int for integers:

let greeting = "Hello"
let age = 30
print_endline greeting
print_int age
print_newline ()

String Concatenation

Use ^ to concatenate strings:

let full = "Hello" ^ ", " ^ "World!"
print_endline full

Your Task

Create a binding language with value "OCaml" and print "I love OCaml" using string concatenation.

JS Transpiler loading...
Loading...
Click "Run" to execute your code.