I have the following code snippet:
class Fish # @message = "I can swim" class << self @message = "I can jump!" define_method(:action) { @message } end end Fish.action => nil
As soon as I uncomment the @message
variable @message
, Fish.action
returns I can swim
. Why in both cases it ignores the message I can jump
. Why is this? Why is the Fish class bound to @message
defined at the beginning, but not inside the singleton
class?
source share