Alpha Chen 2 years ago
parent ac36917f76
commit 5850036689

@ -11,8 +11,21 @@ module Lox
def find_method(name) = @methods[name] def find_method(name) = @methods[name]
def to_s = name def to_s = name
def call(interpreter, args) = Instance.new(self)
def arity = 0 def call(interpreter, args)
instance = Instance.new(self)
if init = find_method("init")
init.bind(instance).call(interpreter, args)
end
instance
end
def arity
init = find_method("init")
init ? init.arity : 0
end
end end
end end

Loading…
Cancel
Save