Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > XOR operator?

Reply
Thread Tools

XOR operator?

 
 
Daniel Carrera
Guest
Posts: n/a
 
      10-28-2003
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,
--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

 
Reply With Quote
 
 
 
 
gabriele renzi
Guest
Posts: n/a
 
      10-28-2003
il Wed, 29 Oct 2003 05:36:01 +0900, Daniel Carrera
<(E-Mail Removed)> ha scritto::

>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 ^
>> 0b0000^0b0111

=> 7


 
Reply With Quote
 
 
 
 
Jim Freeze
Guest
Posts: n/a
 
      10-28-2003
On Wednesday, 29 October 2003 at 5:36:01 +0900, Daniel Carrera wrote:
> 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


--
Jim Freeze
----------
The Roman Rule
The one who says it cannot be done should never interrupt the
one who is doing it.

 
Reply With Quote
 
Daniel Carrera
Guest
Posts: n/a
 
      10-28-2003
Thanks everyone. Yeah, ^ seems to work.



On Tue, Oct 28, 2003 at 03:04:04PM -0600, Lyle Johnson wrote:
> Daniel Carrera wrote:
>
> >I'm trying to figure out what the boolean "xor" operator is in Ruby. I
> >thought it was "^^" but that doesn't work.

>
> It's just a single "^" character, e.g.
>
> six = 2 ^ 4
>
> Hope this helps,
>
> Lyle


--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

 
Reply With Quote
 
Dave Thomas
Guest
Posts: n/a
 
      10-28-2003

On Oct 28, 2003, at 14:36, Daniel Carrera wrote:

> 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.
>


http://www.rubycentral.com/book/ref_...FalseClass._up
http://www.rubycentral.com/book/ref_....Bitoperations

etc


 
Reply With Quote
 
Josef 'Jupp' Schugt
Guest
Posts: n/a
 
      10-28-2003
* 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can use xor logic suma Java 9 05-11-2006 05:39 AM
How can you xor ArrayLists? cryptogirl Java 7 02-26-2006 11:15 PM
XOR Boolean Buck Turgidson Java 9 04-05-2004 09:52 PM
Evaluate such an expression as: (A and B) xor (C or D) evan C++ 1 06-28-2003 06:36 AM
Evaluate such an expression as: (A and B) xor (C or D) evan C++ 0 06-28-2003 05:32 AM



Advertisments