On 12 May 2007, at 11:37, Sebastian Hungerecker wrote: > Human Dunnil wrote: >> I was looking at one of the Ruby Quiz solutions (Countdown) in Ruby >> Quiz book, it uses << operator, which I don't understand! > > If you're looking at the same code as I am, the << isn't used as > the shift > operator. It's used to add items to an array. << only acts as shift > operator > on numbers. The << operator has many different uses: - In an Array it is used to append (push) an object into a given array - In a Fixnum and a Bignum object (i.e integers) it shifts the number bits to the left - In an IO object it will write the object (as a string) to the IO object. - In a String it will append the object (to_s) to the String (if the object is a Fixnum between 0 and 255 it will convert it to the character representation before appending it) I hope this helps... Cheers, Enrique Comba Riepenhausen