|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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/ } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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} 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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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} 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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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! <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: http://www.ruby-lang.org/id/about/ } > > |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 ![]() |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
[Note: parts of this message were removed to make it a legal post.]
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 :-) > > 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 |
|
![]() |
| Outils de la discussion | |
|
|