let x = ref 100 in
let f () = !x in
let x = ref 50 in
??? ; f ()
You are supposed to get the answer to be 50 by plugging something into the ??? (not shadowing). But I don't know how to change the value of your orig开发者_如何学Pythoninal ref now, considering x := 50 is going to apply to the SECOND x now....
If it really is a "beginner question", that's probably not the expected answer. But I don't know what the "expected answer" is, so let's hack around instead.
Obj.(obj (field (repr f) 1)) := 42;;
relevant link
There is no way to access original x now. So.. shadow f!
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论