# Is this a feature or a bug?

**URL:** <https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542>\
**Category:** Ruby\
**Created:** [March 11, 2008, 7:02am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542 "2008-03-11T07:02:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 7:02am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/1 "2008-03-11T07:02:15Z")

</div>

sorry if it’s been discussed as i don’t know what the search keyword  
for this scenario. it actually came up from _mistype_ (notice the  
comma).

m:~ arie$ irb

> > h = {}  
> > =\> {}
> 
> > h[:a] = 1,  
> > ?\> h[:b] = 2  
> > =\> [1, 2]
> 
> > h  
> > =\> {:a=\>[1, 2], :b=\>2}

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 7:15am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/2 "2008-03-11T07:15:10Z")

</div>

On Mon, Mar 10, 2008 at 10:59 PM, Rie! [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > h  
> > > =\> {:a=\>[1, 2], :b=\>2}

This is expected behavior. You’ve assigned a two-element list to h[:a]

- the number 1
- an assignment expression yielding the number 2

Since assignment expressions return their rval, everything’s happy and  
legal.

This one-line version behaves identically to what you’ve typed:

h[:a] = [1, h[:b] = 2]

~ j.

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 7:18am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/3 "2008-03-11T07:18:41Z")

</div>

On Tue, Mar 11, 2008 at 12:59 AM, Rie! [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > h  
> > > =\> {:a=\>[1, 2], :b=\>2}

Feature, I think. Otherwise, you wouldn’t be able to do things like…

a, b = b, a

The comma, it seems, assumes precedence from the right side.

Todd

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 8:31am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/4 "2008-03-11T08:31:40Z")

</div>

menarik, hmm banyak hal2 begini yg gw jg gak tau.

oot gmail keren jg, postingan ari yg cross posting replynya dari  
ruby-talk ama id-ruby bisa jadi satu thread gini 🙂

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 10:17am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/5 "2008-03-11T10:17:21Z")

</div>

rofiq wrote:

> menarik, hmm banyak hal2 begini yg gw jg gak tau.
> 
> oot gmail keren jg, postingan ari yg cross posting replynya dari  
> ruby-talk ama id-ruby bisa jadi satu thread gini 🙂

this looks like rot13 🙂

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 11, 2008, 10:56am UTC](https://www.ruby-forum.com/t/is-this-a-feature-or-a-bug/131542/6 "2008-03-11T10:56:02Z")

</div>

On Tue, Mar 11, 2008 at 8:15 PM, S2 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rofiq wrote:
> 
> > menarik, hmm banyak hal2 begini yg gw jg gak tau.
> > 
> > oot gmail keren jg, postingan ari yg cross posting replynya dari  
> > ruby-talk ama id-ruby bisa jadi satu thread gini 🙂
> 
> this looks like rot13 🙂

"zranevx, uzz onalnx uny2 ortvav lt tj wt tnx gnh.

bbg tznvy xrera wt, cbfgvatna nev lt pebff cbfgvat ercylaln qnev  
ehol-gnyx nzn vq-ehol ovfn wnqv fngh guernq tvav :-)"

Our normal methods are useless here!

Arlen
