Shouldn't it be self >> class, or am I dyslexic?

The semantics of

class X

class << self
def instance_method_for_class_object_named_X

end
end

end

is that an instance method is added (appended) to the current object X
== self by
the class definition that encloses the new method. Because we are
appending a new method to self, the arrows should point towards “self”
not “class.”

nbits

Oops,

Subject should read “… class >> self …”

(Ok, maybe I am dyslexic – but I’m still right – just takes me a
couple
of tries to get the sequencing right.) :slight_smile:

Ben T. wrote:

The semantics of

class X

class << self // I think it should be class >> self.
def instance_method_for_class_object_named_X

end
end

end

is that an instance method is added (appended) to the current object X
== self by
the class definition that encloses the new method. Because we are
appending a new method to self, the arrows should point towards “self”
not “class.”

nbits

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs