From: Alex Gutteridge Date: 2007-08-21T15:57:45+09:00 Subject: Re: (String * Fixnum) and (Fixnum * String) On 21 Aug 2007, at 15:12, Dan wrote: > I understand that ruby being strongly typed means you can only do > "sensible" > things with the types you are working with. However, aren't the > examples > above pretty much equivalent? or is it a precedence thing? Trying > to answer > my own question is it because the "*" operator for a Fixnum only > accepts > another Fixnum/Bignum, while the "*" operator for a String only > allows a > Fixnum, because it sure doesn't let you do String * String (and why > would > you really). To clarify my previous answer, the important thing is to realise that most 'operators' in Ruby are just methods that look funny. So 3 * 2 Is just another way of writing 3.* 2 or 3.send(:*,2) And hence 'foo' * 2 is very different to 2 * 'foo' in terms of the underlying method that is called. Alex Gutteridge Bioinformatics Center Kyoto University