Hi --

On Sat, 12 May 2007, Human Dunnil wrote:

> Thanks for the info, I knew << method is implemented by different
> classes for different tasks. I really need info on bitwise operator.
>
> If you look at Ruby Quiz book (Page 240), you see:
>
> @num_sources = sources.size
> @num_hashes = 1 << @num_sources
>
> I think << here is doing bit manipulation, which I do not get!

It's got to do with binary arithmetic.  For example, let's say you do:

   12 << 2

In binary notation, 12 is 1100.  If you shift that to the left by 2
(i.e., << 2), you get 110000, which is 48:

   12 << 2
   => 48


David

-- 
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)