From: Gary Wright Date: 2009-01-11T06:03:44+09:00 Subject: Re: What is meant by << operator ??? On Jan 10, 2009, at 3:29 PM, FrihD wrote: > Muhammad mohsin ali Ma wrote: >> What is meant by << operator? > > It is not an operator, but actually is the method "<<". So it > depends on the object that receives this method. We just had a long rambling thread about operators vs. methods: I'd describe '<<' as a re-definable operator. Syntactically it is an operator but its semantics are defined by an associated method. Ruby also has operators that can't be redefined: || && or and not ! ?: There are often semantics associated with operators that shouldn't be disregarded without thought. For example: lhs << rhs often means that rhs will 'added' to lhs modifying lhs in the process. On the other hand: lhs + rhs generally means new object formed by 'adding' rhs' to 'lhs' will be returned and that lhs will not be modified. Ruby doesn't enforce these semantics but developers shouldn't ignore them either. Gary Wright