On 5/12/07, John Joyce <dangerwillrobinsondanger / gmail.com> wrote:
> It's not what you think. Not always.

>
> In the class BigNum and the class FixNum, << is a left shift bit
> shift operator.
...

> With class IO (and its subclasses, such as File)
> << writes the object on the right to the IO object on the left. It
> also converts the object on the right to a string first.
>
> Class String uses << to append the object on the right to the string
> object on the left. Conversion to string first will happen.

and Date#<<(n) produces a date n months earlier than the receiver.

> This may actually be a weakness of Ruby, maybe not. (could be a
> contentious issue) but much like in natural languages, context makes
> it pretty clear that something different is happening.

I think that this analogy with natural languages goes hand in hand
with what makes Ruby seem natural to some of us, which actually makes
it a strength.

It's also a nice counter-example for those who try to 'tighten-up'
duck-typing by using respond_to?, it's not just the name but semantics
that matter.  Again to me this is a strength, others will no doubt see
it differently.  It's really no different than the cases which
strongly typed languages fail to catch such as sqrt(-1) in a language
which doesn't support complex numbers.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/