我试图在对象方法的上下文中找出 OCaml 的递归。我尝试了以下代码,但似乎无法编译。
class foo =
object (self)
 method loopTest =
  let rec doIt x =
   Printf.printf "%d\n" x;
   if x>1 then doIt (x+1)
end;;
如何在方法中创建此类递归函数?
修改后的代码:
class foo =
object (self)
 method loopTest =
  let rec doIt x =
   Printf.printf "%d\n" x;
   if x<10 then doIt (x+1) in doIt 0
end;;