From: Robert Klemme Date: 2006-04-29T20:10:14+09:00 Subject: Re: class returns value without method or attribute 2006/4/29, kris : > I like the idea of using inspect, will this also allow me to assign > value like: > money = Money.new > money = 5 No, inspect will only affect output with p (or in IRB). > Also do I need to add a method for + and -, is there not a module like > Comparable that I can mixin to get this functionality? Comparation and arithmetic are two orthogonal concepts, i.e. completely unrelated. If you want arithmetic in your class, you need to override +, - and coerce. http://www.rubygarden.org/ruby?CoerceExplanation http://www.rubygarden.org/?terms=coerce&submit=SEARCH&handler=searching For ordering there is mixin Comparable http://ruby-doc.org/core/classes/Comparable.html http://www.rubycentral.com/book/ref_m_comparable.html > Are there any other typical methods I should be adding? Excluding the > money specific stuff I have to_s. to_int is an option, too, if your instance is equivalent to an int. Additionally you should implement to_i and to_f. Kind regards robert -- Have a look: http://www.flickr.com/photos/fussel-foto/