On Mon, 28 May 2001, Robert Feldt wrote:
> On Mon, 28 May 2001, Mirian Crzig Lennox wrote:
> > This gives me an idea:  how about a module which implements all the
> > operators with default behavior by calling the object's to_int method?
> > That way, a class could include this module and then only override the
> > methods which will be different for that class.  Would this work?
> Yes, it would. MetaRuby takes a similar approach on other classes so you
> might want to check if Mathieu has started on the Numeric-related classes
> yet.



Three months ago I have written:



module ArithInterface
	def +(other); raise NotImplementedError; end
	def -@; raise NotImplementedError; end
end

module ArithMixin
	include ArithInterface
	def -(other)
		self + - other
	end
end



and then I stopped there. ;-)

matju