Is the below statement holds true in the course of instantiation relations ? (a) BasicObject is an instance of Class (as well as (kind) of Module, Object, BasicObject). (b) Object is an instance of Class (as well as (kind) of Module, Object, BasicObject).
on 2013-02-23 11:48
on 2013-02-23 12:16
On Sat, Feb 23, 2013 at 11:49 AM, Love U Ruby <lists@ruby-forum.com> wrote: > Posted via http://www.ruby-forum.com/. > Hi 'Love U Ruby'. There is a method that seems all you need in this case: = .instance_of? (from ruby core) === Implementation from Object ------------------------------------------------------------------------------ obj.instance_of?(class) -> true or false ------------------------------------------------------------------------------ Returns true if obj is an instance of the given class. See also Object#kind_of?. class A; end class B < A; end class C < B; end b = B.new b.instance_of? A #=> false b.instance_of? B #=> true b.instance_of? C #=> false http://ruby-doc.org/core-1.9.3/Object.html#method-... Hope this helps. Yup! e.
on 2013-02-23 12:43
Edoardo Rossi wrote in post #1098566: > On Sat, Feb 23, 2013 at 11:49 AM, Love U Ruby <lists@ruby-forum.com> > wrote: >> Posted via http://www.ruby-forum.com/. >> > > Hi 'Love U Ruby'. > > There is a method that seems all you need in this case: > > = .instance_of? > > (from ruby core) > === Implementation from Object > ------------------------------------------------------------------------------ > obj.instance_of?(class) -> true or false > > ------------------------------------------------------------------------------ > > Returns true if obj is an instance of the given class. See also > Object#kind_of?. I wanted to ask that - How BasicObject can also be a (kind) of Module, Object, BasicObject)? and How Object can also be a (kind) of Module, Object, BasicObject)?
on 2013-02-23 15:43
you dont understand! its the class BasicObject itself wich is an instance of Class. not the instances of BasicObject
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.