Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > is this a feature or a bug?

Reply
Thread Tools

is this a feature or a bug?

 
 
Rie!
Guest
Posts: n/a
 
      03-11-2008
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: http://www.ruby-lang.org/id/about/ }

 
Reply With Quote
 
 
 
 
John Barnette
Guest
Posts: n/a
 
      03-11-2008
On Mon, Mar 10, 2008 at 10:59 PM, Rie! <> 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}


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.

 
Reply With Quote
 
 
 
 
Todd Benson
Guest
Posts: n/a
 
      03-11-2008
On Tue, Mar 11, 2008 at 12:59 AM, Rie! <> 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

 
Reply With Quote
 
rofiq
Guest
Posts: n/a
 
      03-11-2008
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

On Tue, Mar 11, 2008 at 12:59 PM, Rie! <> 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: http://www.ruby-lang.org/id/about/ }
>
>


 
Reply With Quote
 
Arlen Cuss
Guest
Posts: n/a
 
      03-11-2008
[Note: parts of this message were removed to make it a legal post.]

On Tue, Mar 11, 2008 at 8:15 PM, S2 <> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
API for signal strength value with zero configuration feature on? =?Utf-8?B?a2Fu?= Wireless Networking 3 09-04-2005 11:13 PM
Disable the wireless network feature =?Utf-8?B?UmFqYXNla2FyYW4=?= Wireless Networking 1 05-04-2005 01:46 AM
Begging for a new feature! Alan P Firefox 2 04-03-2004 09:34 AM
bug or feature? Pedro Graca Firefox 3 01-02-2004 06:42 PM
feature question Jacob Farr Firefox 2 11-13-2003 09:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57