On May 29, 12:15 pm, Rohan Dey <rohan... / gmail.com> wrote:
> unknown wrote:
> > Hi,
>
> > I'm playing around with ruby trying to understand whats going on, and
> > here is something I don't understand.
>
> > class ZNum
> >   def initialize(n)
> >     @n=n
> >   end
> >   def to_s
> >     self.class
> >   end
> > end
>
> > n = ZNum.new(1234)
>
> > puts n            # prints #<ZNum:0xb75dfcc8>
> > puts n.to_s     # prints ZNum
>
> > In both cases it uses ZNum#to_s, but the results are different. Why?
>
> > /kim
>
> Not able to understand what you are actually asking. Can you put little
> detail on this.
>
> --
> Posted viahttp://www.ruby-forum.com/.

I'm working on an interface for some legacy data.
The legacy data will be stored in objects as ruby numbers (fixnum,
bignum and float), but I need to override ruby's number formating. My
example above has no practical value, it's just some odd behavior that
I would like to understand before I design my legacy interface.

/kim