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