Hi,
At Sat, 24 Apr 2004 12:08:26 +0900,
Hal Fulton wrote in [ruby-talk:98192]:
> But then, pushing hash is illegal in most countries.
IMHO, sometime it feels convenient.
$ irb --prompt xmp
class Hash
alias << :update
end
==>nil
table = Hash.new {{}}
==>{}
table["foo"] <<= {"x"=>1}
==>{"x"=>1}
table
==>{"foo"=>{"x"=>1}}
table["bar"]
==>{}
table
==>{"foo"=>{"x"=>1}}
Since <<= is assignment "foo" is added, but "bar" is not.
--
Nobu Nakada