class backup =
object (self : 'mytype)
val mutable copy = None
method save = copy <- Some {< copy = None >}
method restore = match copy with Some x -> x | None -> self
end;;
在這段代碼中,有幾件事情我不太明白。OCaml:對象定義和克隆
(self:'mytype)self意味着遞歸類,但'mytype?'的作用是什麼?
有些{}獲取備份副本,其中副本仍爲無,並將其分配給副本?
謝謝!