forked from luna/jorts
23 lines
328 B
Text
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}")
|
||
|
}
|