主题:Ruby定义静态方法
主题:Ruby定义静态方法有两种方法
1. 开源框架喜欢用的方式Ruby代码
class Test
class << self
def a
puts "static method"
end
end
end
class Test
class << self
def a
puts "static method"
end
end
end 2. 我喜欢用的方式
Ruby代码class Test
def self.a
puts "static method"
end
end
class Test
def self.a
puts "static method"
end
end 调用就很简单了 谢谢啊:em27: 一知半解啊
页:
[1]