R
Robo
When defining class methods, are these two ways the same? Is there a
preference on which one should be use?
class Monkey
def self.method1
puts "method1"
end
def Monkey.method2
puts "method2"
end
end
I would think self.method1 is more preferable 'cos it doesn't have to
get rename when the class name gets change.
Also, I see them get call in two different ways, Monkey.method1 and
Monkey::method1. Both seems to work, are they identical? Is there an
idiom on which way should be use?
Robo
preference on which one should be use?
class Monkey
def self.method1
puts "method1"
end
def Monkey.method2
puts "method2"
end
end
I would think self.method1 is more preferable 'cos it doesn't have to
get rename when the class name gets change.
Also, I see them get call in two different ways, Monkey.method1 and
Monkey::method1. Both seems to work, are they identical? Is there an
idiom on which way should be use?
Robo