ruby 설명서의 module_function에있는 예제를 보았습니다. Mod.one이 오래된 "this is one"을 반환하고 c.one이 업데이트 된 "this is new one"을 반환하는 코드의 후반 부분을 이해하지 못합니다. 어떻게 이런 일이이 문서 Mod.one는 이전 코드 만 CLS 개체가 새 액세스 할 수 있습니다를 반환 왜ruby 설명서의 module_function 예제
module Mod
def one
"This is one"
end
module_function :one
end
class Cls
include Mod
def call_one
one
end
end
Mod.one #=> "This is one"
c = Cls.new
c.call_one #=> "This is one"
module Mod
def one
"This is the new one"
end
end
Mod.one #=> "This is one"
c.call_one #=> "This is the new one"
에서 실제 코드입니다
일이 무엇입니까? 감사합니다. .
'callOne'을'call_one'으로 편집하려고했는데, 당신이 문서에서 이와 같이 언급했다는 것을 제외하고는. 나는 이것에 대한 버그 보고서를 어떤 단계에서 제출할 것이다. –
이제 수정되었습니다. http://redmine.ruby-lang.org/issues/4469 –