10 << 20 does bit-wise left shift 20 times.
Gennady.
路路路
-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Charlie
Sent: Friday, May 05, 2006 18:00
To: ruby-talk ML
Subject: Re: Constant in Ruby.Austin Ziegler wrote:
> On 5/5/06, Charlie <peckcharlie@yahoo.com> wrote:
>> from (irb):7
>> from :0
>
> Do you understand *why* that worked? Consider it from:
>
> A = "Foo"
> B = A
> B.freeze
> A << "Bar"
>
> -austinI show the object_id just for clarity, to show that A and B is
'referencing' or 'pointing' to the same object, although they do
nothing. I thought I understand it until I try the example below for
integers. Instead of showing errors, it gave very large bogus
numbers,
although results remain intact in the end. So, the answer to your
question is that I don't. I think I might have missed out something
here.A = 10 => 10
B = A => 10
B.freeze => 10
A << 20 => 10485760
B << 40 => 10995116277760
A => 10
B => 10
A.object_id => 21
B.object_id => 21--
Posted via http://www.ruby-forum.com/\.