From: "F. Senault" Date: 2008-05-29T17:49:56+09:00 Subject: Re: The duck's backside Le 29 mai � 06:45, Eleanor McHugh a �crit : > On 28 May 2008, at 23:23, Mark Wilden wrote: >> That's true, but it wasn't my point. The question is whether all >> methods with the same name in all active classes should be >> semantically equivalent. I think that's a rather larger assumption >> than that Numeric means "numeric." > > Numeric may well mean "numeric" in some particular sense, but that is > only a subset of all objects which may have a valid numeric > representation. As I said, you're applying a static typing mindset to > a place where it's not necessary and whilst Ruby will let you do that, > in the long term you'll find yourself doing much more work with very > little (if any) gain in software robustness. In fact if you're writing > a library you'll introduce additional fragility to code interfacing > with it because Ruby programmers generally expect Duck Typing and > write accordingly. BTW, your code makes in fact two assumptions : - The object has a valid numeric value (via .to_i(nt) in your case), - But also that the object has a _string_ representation that happens to be that numeric value (via the #{} interpolation). Wouldn't it be better to write this : @post "first=#{a}&" + (b.nil? ? "second=ignored&third=#{v.to_int}" : "second=#{v.to_int}&third=ignored") > Ellie Fred -- Steps have been taken, a silent uproar Has unleashed the dogs of war You can't stop what has begun Signed, sealed, they deliver oblivion We all have a dark side, to say the least And dealing in death is the nature of the beast (Pink Floyd, Dogs of War)