On Thu, Sep 27, 2012 at 2:30 PM, Damián M. González <[email protected]> wrote: >> Why are you subclassing Date in the first place? > > Well, the class Dia(It's day in spanish) represent a day. Each instance > of this class have like 10 inst. variables. I wanted to subclass Date > because I want to be available +() or -() or cweek() to a Dia instance, > in the way that it behave like a Date object does.
Then better use composition as has been suggested. Inheriting core classes is rarely a good idea. What you have is actually something else which happens to have a data attached to it as well. If you need numeric operations one of my blog articles might help you to implement operators properly: http://blog.rubybestpractices.com/posts/rklemme/019-Complete_Numeric_Class.html Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
