T
T.G.
Hi,
consider following code:
#!/usr/bin/env ruby
class Foo
def self.bar
puts "class method called"
end
def some_method
Foo.bar # -----> self.bar will not work here
end
end
foo = Foo.new
foo.some_method
although I can define the class method using "self", I have to use
class name to invoke the class method within the class. it would be
nice if I can invoke class method without explicitly using it's name,
so when I change my class name, I only need to change it in one place.
any way to do this?
Thanks!
consider following code:
#!/usr/bin/env ruby
class Foo
def self.bar
puts "class method called"
end
def some_method
Foo.bar # -----> self.bar will not work here
end
end
foo = Foo.new
foo.some_method
although I can define the class method using "self", I have to use
class name to invoke the class method within the class. it would be
nice if I can invoke class method without explicitly using it's name,
so when I change my class name, I only need to change it in one place.
any way to do this?
Thanks!