From: kimersen@... Date: 2007-05-29T22:05:09+09:00 Subject: Re: Overriding to_s On May 29, 12:15 pm, Rohan Dey 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 # > > 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