Ask a Question related to Ruby, Design and Development.
-
Daniel Carrera #1
XOR operator?
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".
Daniel Carrera Guest
-
operator
Hello, I would like to known if it is possible to implement operator like + += etc like we can do in c++. class object { object&... -
Operator overloading
Hi, With Ruby operaotr overloading is simply done by a definition like class foo ... def +( other ) # some code end -
operator |=
hello, what does the operator |= mean? I saw it in a script : $output = "png"; $style = BCS_ALIGN_CENTER; $style |= ($output == "png"... -
or operator
Typeo should be $my not #my -----Original Message----- From: Paul Kraus Sent: Friday, August 29, 2003 1:55 PM To: 'Nigel Peck - MIS Web... -
BETWEEN OPERATOR
Hi people. Does anyone know if is better to use the BETWEEN operator than >= and <= ? I need to know what Microsoft says about it ? Thank you... -
Mark J. Reed #2
Re: XOR operator?
On Wed, Oct 29, 2003 at 05:36:01AM +0900, Daniel Carrera wrote:
The xor operator in Ruby is ^ (just one). It serves as both bitwise> 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?
and Boolean, depending on its arguments:
irb(main):001:0> 2 ^ 1
=> 3
irb(main):002:0> true ^ false
=> true
irb(main):003:0> true ^ true
=> false
-Mark
Mark J. Reed Guest
-
gabriele renzi #3
Re: XOR operator?
il Wed, 29 Oct 2003 05:36:01 +0900, Daniel Carrera
<dcarrera@math.umd.edu> 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 ^=> 7>> 0b0000^0b0111
gabriele renzi Guest
-
Lyle Johnson #4
Re: XOR operator?
Daniel Carrera wrote:
It's just a single "^" character, e.g.> I'm trying to figure out what the boolean "xor" operator is in Ruby. I
> thought it was "^^" but that doesn't work.
six = 2 ^ 4
Hope this helps,
Lyle
Lyle Johnson Guest
-
Jim Freeze #5
Re: XOR operator?
On Wednesday, 29 October 2003 at 5:36:01 +0900, Daniel Carrera wrote:
irb(main):001:0> 1 ^ 0> 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?
=> 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.
Jim Freeze Guest
-
Dalibor Sramek #6
Re: XOR operator?
On Wed, Oct 29, 2003 at 05:36:01AM +0900, Daniel Carrera wrote:
Neither Ruby in a Nutshell mentions one. However I made a quick tests and it> 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.
seems it is safe to use ^ for integers.
Dalibor
--
Dalibor Sramek [url]http://www.insula.cz/dali[/url] | In the eyes of cats,
[email]dalibor.sramek@insula.cz[/email] | all things belong to cats.
Dalibor Sramek Guest
-
Daniel Carrera #7
Re: XOR operator?
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".
Daniel Carrera Guest
-
Dave Thomas #8
Re: XOR operator?
On Oct 28, 2003, at 14:36, Daniel Carrera wrote:
[url]http://www.rubycentral.com/book/ref_c_falseclass.html#FalseClass._up[/url]> 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.
>
[url]http://www.rubycentral.com/book/ref_c_fixnum.html#Fixnum.Bitoperations[/url]
etc
Dave Thomas Guest
-
Josef 'Jupp' Schugt #9
Re: XOR operator?
* Daniel Carrera; Wed, 29 Oct 2003 06:28:45 +0900
[...as an XOR operator]> Thanks everyone. Yeah, ^ seems to work.
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
Josef 'Jupp' Schugt Guest
-
Mark J. Reed #10
Re: XOR operator?
On Tue, Oct 28, 2003 at 11:21:33PM +0000, Josef 'Jupp' Schugt wrote:
AFAIK, Ruby got it from Perl, which got it from Fortran, only because> 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)?
C has no exponentiation operator and ^ was taken by XOR.
-Mark
Mark J. Reed Guest



Reply With Quote

