0
執行的
我有下面這段代碼:程序OCaml中
let p = print_string("finished\n");;
let x0 = ref 0;;
class point =
object
val mutable x = incr x0; !x0
method get_x = x
method move d = x <- x + d
end
;;
print_int(new point#get_x);;
p;;
print_int(new point#get_x);;
p;;
不明白爲什麼輸出是:
finished
12
我的期望其實是這樣的:
1
finished
2
finished
任何人都可以知道執行這段代碼的正確順序是什麼?