Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
let x = ref 100 in let f () = !x in let x = ref 50 in ??? ; f ()
您应该通过将某些东西插入 ??? 得到 50 的答案 (不是阴影)。但是我现在不知道如何更改原始 ref 的值,考虑到 x := 50 现在将应用于 SECOND x ....
如果它真的是一个“初学者问题”,那可能不是预期的答案。但是我不知道“预期的答案”是什么,所以让我们改一下。
Obj.(obj (field (repr f) 1)) := 42;;
相关链接
现在没有办法访问原版x了。所以..影子f!
x
f