PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > is this a feature or a bug?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
is this a feature or a bug?

Réponse
 
LinkBack Outils de la discussion
Vieux 11/03/2008, 06h59   #1
Rie!
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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: http://www.ruby-lang.org/id/about/ }

  Réponse avec citation
Vieux 11/03/2008, 07h12   #2
John Barnette
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is this a feature or a bug?

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.

  Réponse avec citation
Vieux 11/03/2008, 07h17   #3
Todd Benson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is this a feature or a bug?

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

  Réponse avec citation
Vieux 11/03/2008, 08h18   #4
rofiq
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is this a feature or a bug?

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/ }
>
>


  Réponse avec citation
Vieux 11/03/2008, 10h12   #5
S2
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is this a feature or a bug?

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
  Réponse avec citation
Vieux 11/03/2008, 10h53   #6
Arlen Cuss
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is this a feature or a bug?

[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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11351 seconds with 14 queries