LearnRubyTheHardWay のチュートリアルに従って、バージョン 1.9.3 で Ruby を学習しています。
内で関数を定義する場合、次のようにModule
、関数名の前にモジュール名を付ける必要があるようです。
module MyStuff
def MyStuff.apple()
puts "I AM APPLES!"
end
end
MyStuff.apple()
なぜこれができないのですか:
module MyStuff
def apple()
puts "I AM APPLES!"
end
end
MyStuff.apple() # this does not work
Ruby ドキュメントには、上記のような例があります。
私は何を間違えていますか?