我很困惑如何調用在同一個類中定義的另一個函數內的類中定義的函數。這是我做了什麼:在ruby中調用非靜態函數
class Test
def TestFunc(obj)
puts obj
end
def Test.StatFun(obj)
puts obj
TestFunc(obj)
end
end
Test.StatFun([[5,2], [4,3]])
當我在cmd.exe
運行它,我得到以下錯誤:
ruby LawtonTest.rb 5 2 4 3 LawtonTest.rb:10:in
StatFun': undefined method
TestFunc' for Test:Class (NoMet hodError) from LawtonTest.rb:14:in `'
我無法弄清楚。任何幫助將不勝感激。
我已經寫了一篇Ruby的介紹,可能會幫助你:http://www.apeth.com/rubyIntro/justenoughruby.html – matt