Newsgroups: comp.lang.ruby
From: dbl...@wobblini.net
Date: Mon, 3 Sep 2007 11:19:09 +0900
Local: Sun, Sep 2 2007 10:19 pm
Subject: Re: assigning to hash keys when there is a default value?
Hi --
On Mon, 3 Sep 2007, 7stud -- wrote: x ||= y is, I think, always supposed to be exactly equivalent to > Can someone explain why there is a difference in the second line of > output for the two hashes: > h = Hash.new(5) > puts h[2] > h[2] ||= 10 > #---------- > h = Hash.new > puts h[2] > h[2] ||= 10 > ---output:-- > nil x = x || y, so that line in your first hash should be equivalent to: h[2] = 5 || 10 which should assign 5 to h[2]. It looks to me like you've found a bug. David -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||