a = “mom”
if a == ( “dad” || “mom” )
puts “Hi”
end
Very simple. I saw a kind of this exercise in a book that I’m studing(
yes…I’m noob in this ), and I gave it by understood, but now when I’m
practicing i see that…this has not happen. That chunk of code return
me nil…but, judging by the book, that should return me “Hi” right?
Because I say: if a is equal to “dad” or “mom” say “Hi”. I don’t know if
is my OS( Windows XP SP3( I’ve had several troubles with it )) or if is
the last version of Ruby, which I am using, the 1.9.3 or what…
I’ll appreciate your time guys, thanks.
On Wednesday 16 November 2011 06:09:57 Damin M. Gonzlez wrote:
me nil…but, judging by the book, that should return me “Hi” right?
Because I say: if a is equal to “dad” or “mom” say “Hi”. I don’t know if
is my OS( Windows XP SP3( I’ve had several troubles with it )) or if is
the last version of Ruby, which I am using, the 1.9.3 or what…
I’ll appreciate your time guys, thanks.
The || operator returns the left operator if it is a true value
(everything
except nil and false) and the right operand if the left one is a false
value.
Since “dad” is a true value, that’s what || will return. The if
expression
will be equivalent to:
–
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
Sponsor:
Capodanno a Riccione, Pacchetto Relax: Mezza Pensione + bagno turco +
solarium + massaggio. Wifi e parcheggio gratis. 2 giorni euro 199 a
persona
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid977&d)-12
-----Messaggio originale-----
Da: Damin M. Gonzlez [mailto:[email protected]]
Inviato: marted 15 novembre 2011 22:10
A: ruby-talk ML
Oggetto: Logical operator ||
Ey guys. Look at this:
a = “mom”
if a == ( “dad” || “mom” )
puts “Hi”
end
Very simple. I saw a kind of this exercise in a book that I’m studing(
yes…I’m noob in this ), and I gave it by understood, but now when I’m
practicing i see that…this has not happen. That chunk of code return
me
nil…but, judging by the book, that should return me “Hi” right?
Because I say: if a is equal to “dad” or “mom” say “Hi”. I don’t know if
is
my OS( Windows XP SP3( I’ve had several troubles with it )) or if is the
last version of Ruby, which I am using, the 1.9.3 or what…
I’ll appreciate your time guys, thanks.
–
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
Sponsor:
Capodanno a Riccione, Pacchetto Relax: Mezza Pensione + bagno turco +
solarium + massaggio. Wifi e parcheggio gratis. 2 giorni euro 199 a
persona
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid979&d)-12
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.