Issue #14105 has been updated by jeremyevans0 (Jeremy Evans).


`^` is used as the exclusive-or operator in many other programming languages including C, C++, C#, D, Java, Perl, PHP and Python.

If a user wants to use `xor` instead of `^`, they can always alias it manually:

~~~ruby
class Set
  alias xor ^
end
~~~

In general I prefer that users add their own aliases.  I don't think Ruby should add aliases unless the current method names are so bad as to be misleading, and I don't believe that to be the case here.

Note that the following core classes also use `^` for exclusive-or:

* Integer
* FalseClass
* TrueClass
* NilClass

One counterpoint is that Set already aliases `&` to `intersection` and `|` to `union`, so adding `xor` would be consistent in that sense.

----------------------------------------
Feature #14105: Introduce xor as alias for Set#^
https://bugs.ruby-lang.org/issues/14105#change-67802

* Author: ana06 (Ana Maria Martinez Gomez)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Not sure if I should also add feautures for the `Set` class here or if I should do it somewhere else.

I would like to add a more readable method for the exclusive or, currently as `^` in set. It is in both mathematics, hardware and many other programming languages known as `xor`, so I think this will help to use it.

---Files--------------------------------
firefox.desktop (528 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>