@ -11,8 +11,21 @@ module Lox
def find_method(name) = @methods[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
def arity
init = find_method("init")
init ? init.arity : 0