Object Class
These public methods are in the Object class, the base class for Ruby. This documentation is adapted and abbreviated from http://www.ruby-doc.org/core/classes/Object.html, where you can find code examples and longer explanations. Object includes the Kernel module, whose methods are listed in the next section.
Object Instance Methods
obj==other[or]obj.equal?(other)[or]obj.eql?(other)At the
Objectlevel,==returnstrueonly ifobjandotherare the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning. Unlike==, theequal?method should never be overridden by subclasses: it is used to determine object identity (that is,a.equal?(b)if and only ifais the same object asb). Theeql?method returnstrueifobjandotherhave the same value.obj===otherFor class
Object, effectively the same as calling==, but typically overridden by descendants to provide meaningful semantics in case statements.obj=˜otherOverridden by descendants (notably
RegexpandString) to provide meaningful pattern-match semantics.obj._ _id_ _[or]obj.object_idReturns an integer identifier for
obj. The same number will be returned on all calls toidfor a given object, and no two active objects will share anid.Object#object_idis a different concept from the:namenotation, which returns the symbolidofname. Replaces the deprecatedObject#id.obj.classReturns the class of
obj, now preferred overObject#type, because an object’s type in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access