Gavin Kistner
11/3/2004 3:21:00 PM
On Nov 3, 2004, at 7:14 AM, Florian Weber wrote:
> how can i make that the example below returns 'Hello, my name is test'?
One way:
module ClassMethods
attr_accessor :bar
end
class Foo
extend ClassMethods
self.bar = "test"
def hi
puts "Hello, my bar is #{self.class.bar}"
end
end
Foo.new.hi
--
"Despite the surge of power you feel upon learning Ruby,
resist the urge to trip others or slap them in the bald head.
DO NOT LORD YOUR RUBYNESS OVER OTHERS!"
- Why the Lucky Stiff