XOR operator?

D

Daniel Carrera

Hi all,

I'm trying to figure out what the boolean "xor" operator is in Ruby. I
thought it was "^^" but that doesn't work. I searched through PickAxe and
couldn't find a mention of xor.

Does Ruby have an xor?

Cheers,
 
G

gabriele renzi

il Wed, 29 Oct 2003 05:36:01 +0900, Daniel Carrera
Hi all,

I'm trying to figure out what the boolean "xor" operator is in Ruby. I
thought it was "^^" but that doesn't work. I searched through PickAxe and
couldn't find a mention of xor.


it is just one ^=> 7
 
J

Jim Freeze

Hi all,

I'm trying to figure out what the boolean "xor" operator is in Ruby. I
thought it was "^^" but that doesn't work. I searched through PickAxe and
couldn't find a mention of xor.

Does Ruby have an xor?

irb(main):001:0> 1 ^ 0
=> 1
irb(main):002:0> 1 ^ 1
=> 0
irb(main):003:0> 0 ^ 0
=> 0
irb(main):004:0> 0 ^ 1
=> 1
 
J

Josef 'Jupp' Schugt

* Daniel Carrera; Wed, 29 Oct 2003 06:28:45 +0900
Thanks everyone. Yeah, ^ seems to work.
[...as an XOR operator]

One should add that the exponentiation operator is '**'.
Matz, does that syntax mean that Ruby also has COBOL or FORTRAN
heritage (I am not aware of anything else that would justify that
assumption)?

Josef 'Jupp' Schugt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top