1.不用self
class Test class << self def a puts "static method" end end end
?
?
?2. self的方式
?
Ruby代码 ?
class Test def self.a puts "static method" end end
?
调用
?
Ruby代码 ?
Test.a
?转自:http://www.iteye.com/topic/1116041我不敢说我可以忘却,或者勇敢,坚强,等等等等一切堂皇而陈旧的字眼。