新手问题 如何调用类方法????

redhatping · July 14, 2013 · Last by search replied at July 14, 2013 · 2759 hits

class Square

def test_method puts "hello lixiang" end

def self.test_method puts "hello xuqun" end end li=Square.new li.test_method

li 如何调用 self.test_method 类方法,li.self.test_method 错误,li.new.test_method 错误,请教一下大家??

try li.class.test_method

谢谢楼上,解决了。

Square.test_method

You need to Sign in before reply, if you don't have an account, please Sign up first.