[MacRuby] #1091: #inspect behaves differently if class uses #init or custom #init method
#1091: #inspect behaves differently if class uses #init or custom #init method ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ Ruby docs for #inspect say that the default implementation just calls #to_s. (http://www.ruby-doc.org/core/classes/Object.html#M000360) If my class isn't initialized with a custom #init method that doesn't seem to be the case. {{{ class Foo def to_s "I am Foo" end end Foo.new.inspect "I am Foo" class Bar def initMe return self end def to_s "I am Bar" end end Bar.alloc.initMe.inspect "#<Bar:0x2000c0960>" Bar.alloc.initMe.to_s "I am Bar" }}} Should #inspect do something different based on how I initialize my class? -- Ticket URL: <http://www.macruby.org/trac/ticket/1091> MacRuby <http://macruby.org/>
#1091: #inspect behaves differently if class uses #init or custom #init method ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ Comment(by haxie1@…): Replying to [ticket:1091 haxie1@…]:
Ruby docs for #inspect say that the default implementation just calls #to_s. (http://www.ruby-doc.org/core/classes/Object.html#M000360)
If my class is initialized with a custom #init method that doesn't seem to be the case.
{{{ class Foo def to_s "I am Foo" end end
Foo.new.inspect "I am Foo"
class Bar def initMe return self end
def to_s "I am Bar" end end Bar.alloc.initMe.inspect "#<Bar:0x2000c0960>"
Bar.alloc.initMe.to_s "I am Bar" }}}
Should #inspect do something different based on how I initialize my class?
-- Ticket URL: <http://www.macruby.org/trac/ticket/1091#comment:1> MacRuby <http://macruby.org/>
#1091: #inspect behaves differently if class uses #init or custom #init method ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ Comment(by haxie1@…): Replying to [ticket:1091 haxie1@…]:
Ruby docs for #inspect say that the default implementation just calls #to_s. (http://www.ruby-doc.org/core/classes/Object.html#M000360)
If my class isn't initialized with a custom #init method that doesn't seem to be the case.
{{{ class Foo def to_s "I am Foo" end end
Foo.new.inspect "I am Foo"
class Bar def initMe return self end
def to_s "I am Bar" end end Bar.alloc.initMe.inspect "#<Bar:0x2000c0960>"
Bar.alloc.initMe.to_s "I am Bar" }}}
Should #inspect do something different based on how I initialize my class?
My apologies...
If my class isn't initialized with a custom #init method that doesn't seem to be the case.
I meant to say: "if my class is initialized with a custom #init method that doesn't seem to be the case" -- Ticket URL: <http://www.macruby.org/trac/ticket/1091#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby