[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

strange answer by YAML

Michel Demazure

7/12/2007 12:00:00 PM

x,xx = *nil
p x.class => NilClass
p xx.class => NilClass

x, xx= *YAML.load("")
p x.class => FalseClass
p xx.class => NilClass

Feature or bug ?

--
Posted via http://www.ruby-....

2 Answers

Luis Parravicini

7/12/2007 1:53:00 PM

0

On 7/12/07, Michel Demazure <michel@demazure.com> wrote:
> x,xx = *nil
> p x.class => NilClass
> p xx.class => NilClass
>
> x, xx= *YAML.load("")
> p x.class => FalseClass
> p xx.class => NilClass
>
> Feature or bug ?

irb -r yaml
irb(main):001:0> YAML.load("")
=> false

So the return value from load is in a and as there are no more values,
the rest of the variables (in this case xx) gets nil
Without * the results are the same:

irb -r yaml
irb(main):001:0> x,xx = nil
=> [nil]
irb(main):002:0> p x.class
NilClass
=> nil
irb(main):003:0> p xx.class
NilClass
=> nil
irb(main):004:0> x, xx= YAML.load("")
=> [false]
irb(main):005:0> p x.class
FalseClass
=> nil
irb(main):006:0> p xx.class
NilClass
=> nil




--
Luis Parravicini
http://ktulu.co...

Michel Demazure

7/12/2007 6:06:00 PM

0

Luis Parravicini wrote:

> So the return value from load is in a and as there are no more values,
> the rest of the variables (in this case xx) gets nil
> Without * the results are the same:
>

Thanks, MD

--
Posted via http://www.ruby-....