나는이 작품을 알고 :proc를 argument가있는 instance_eval과 함께 호출 하시겠습니까?
proc = Proc.new do
puts self.hi + ' world'
end
class Usa
def hi
"Hello!"
end
end
Usa.new.instance_eval &proc
그러나 나는 시저에 인수를 전달하려는, 그래서이 작동하지 않는이 시도 :
이proc = Proc.new do |greeting|
puts self.hi + greeting
end
class Usa
def hi
"Hello!"
end
end
Usa.new.instance_eval &proc, 'world' # does not work
Usa.new.instance_eval &proc('world') # does not work
이 사람이 나에게 그것이 작동되도록 도와 줄 수 있습니까?
오타가 있습니다. 'gsub! ("gretting", "greeting")' –
지금 고쳐졌습니다. 미안합니다. 고마워. 마크. –