Is this a feature or a bug?

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}

···


r9 = { name: Rie!, ym: riyari3, skype: rubyninja,
blog: http://tinyurl.com/2bjgvn,
ruby: Tentang Ruby }

ID-Ruby
Berdiskusi dan belajar bersama Bahasa Pemrograman Ruby, termasuk segala varian Ruby (JRuby, Rubinius, IronRuby, XRuby), dan program yang dibuat dengan Ruby (Ruby on Rails, JRuby on Rails, Merb)

<*> Kunjungi arsip milis id-ruby di
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
http://www.mail-archive.com/id-ruby-hHKSG33TihhbjbujkaE4pw@public.gmane.org/
http://rubyurl.com/Q8DD
http://news.gmane.org/gmane.comp.lang.ruby.region.indonesia

<*> Baca peraturan id-ruby sebelum posting
http://rubyurl.com/gay1

<*> Ikutilah Jajak Pendapat ID-Ruby
http://rubyurl.com/3CCt

<*> Links ID-Ruby
http://rubyurl.com/n96r

<*> Database ID-Ruby
http://rubyurl.com/Iw3u

<*> Kunjungi Situs Resmi Ruby Indonesia
Bahasa Pemrograman Ruby

<*> Join Ruby Indonesia on Facebook
http://rubyurl.com/QV48

<*> Join Ruby Indonesia on LinkedIn
http://rubyurl.com/eh0i

Yahoo! Groups Links

<*> To visit your group on the web, go to:
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
(Yahoo! ID required)

<*> To change settings via email:
mailto:id-ruby-digest-hHKSG33TihhbjbujkaE4pw@public.gmane.org
mailto:id-ruby-fullfeatured-hHKSG33TihhbjbujkaE4pw@public.gmane.org

<*> To unsubscribe from this group, send an email to:
id-ruby-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos

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.

···

On Mon, Mar 10, 2008 at 10:59 PM, Rie! <ariekusumaatmaja2@gmail.com> wrote:

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}

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

···

On Tue, Mar 11, 2008 at 12:59 AM, Rie! <ariekusumaatmaja2@gmail.com> wrote:

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}

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 :slight_smile:

···

On Tue, Mar 11, 2008 at 12:59 PM, Rie! <ariekusumaatmaja2@gmail.com> wrote:

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}

--
r9 = { name: Rie!, ym: riyari3, skype: rubyninja,
blog: http://tinyurl.com/2bjgvn,
ruby: Tentang Ruby }

"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

···

On Tue, Mar 11, 2008 at 8:15 PM, S2 <non.sto.gioando@nien.te> 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 :slight_smile:

this looks like rot13 :slight_smile: