[MacRuby] #1091: #inspect behaves differently if class uses #init or custom #init method

MacRuby ruby-noreply at macosforge.org
Fri Dec 31 10:57:37 PST 2010


#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/>



More information about the macruby-tickets mailing list