module CallableDict
def method_missing method
puts x["#{method}"]
end
end
위의 코드는 내 모듈이며, 해시 키를 호출 가능하게 만듭니다. 언제 ...하지만 나는 다음과 같은 얻을왜 SystemStackError가 발생합니까?
require 'callabledict'
x = {"foo" => "ruby"}
x.extend CallableDict
x.foo
...
SystemStackError: stack level too deep
from /Users/Solomon/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!
왜 실행? HP는 이것을 고칠 수 있습니까? 루비 오른쪽에서 변수로 x
을 볼 수없는 것처럼
method_missing
의 구현에서
module CallableDict
def method_missing method
puts self["#{method}"]
end
end
을 내가 그 또한 또 다시 X를 호출 한 이후,'재귀 호출이다 method_missing''에서 x'를 호출 같아요. – Peterdk