jorts/examples/closures.jt
2019-03-08 18:30:30 -03:00

23 lines
328 B
Text

import io
fn main () {
x := 0
// since variable are immutable but updatable, x is 1 inside clojure, but
// 0 inside main()
fn inner() {
x++
}
inner()
// shows 0
io.puts("x is {x}")
// however, if you explicitly update x:
x = inner()
// shows 1
io.puts("x is {x}")
}