1 ^ 1 # => 0 1 ^ 2 # => 3 5 ^ 6 # => 3
These are the results I am getting. Can, please, somebody explain how ^
works?
inject(:+) is not Symbol#to_proc, :+ has no special meaning in the ruby language - it's just a symbol.
A caret (sometimes called a "text cursor") is an indicator displayed on the screen to indicate where text input will be inserted.
The and keyword in Ruby takes two expressions and returns “true” if both are true, and “false” if one or more of them is false. This keyword is an equivalent of && logical operator in Ruby, but with lower precedence.
It's a bitwise XOR (exclusive OR). It evaluates to True if and only if its arguments differ (one is True , the other is False ). A slightly more illustrative example might include both numbers having 1 in the same bit to make it clear that 1 xor 1 = 0 .
It's a bitwise XOR operator.
For each bit in the binary representation of the operands, a bitwise XOR will get a 1 bit if one of the corresponding bits in the operands is 1, but not both, otherwise the XOR will get a 0 bit. Here's an example:
5 = 101 6 = 110 5 ^ 6 = 011 = 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With