4
創建類
我知道OCaml中,我們可以創建一個類執行以下操作:OOP - 怎樣才能在ReasonML
class stack_of_ints =
object (self)
val mutable the_list = ([] : int list) (* instance variable *)
method push x = (* push method *)
the_list <- x :: the_list
end;;
不過,我一直掙扎在如何做到這一點在尋找文檔原因。謝謝。
類有它們的用例,他們只是很少見。 – RichouHunter