Issue #14924 has been updated by mame (Yusuke Endoh).


Changing the behavior of Integer#/ has been already rejected.

https://bugs.ruby-lang.org/issues/5512#note-12

> Too big incompatibility. Abandoned.
>
> Matz.

It might be possible to add a new operator // as an alias to Integer#quo, but it also brings (relatively small) incompatibility.  For example,

```
x = str.split //
foobar
```

the program above might be interpreted as `x = (str.split) // (foobar)` if an operator // is added.

----------------------------------------
Feature #14924: // floor division operator
https://bugs.ruby-lang.org/issues/14924#change-73038

* Author: deneb (Sbastien Durand)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hello!

In my job, I have to do many math operations. And it's kind of a pain because of integer division (3 / 2 == 1). I have to constantly cast integers to floats.

Would it be a good idea to always return a float when you divide two numbers? I mean, 99% of the time you just want that. (The principle of least surprise.)

Python is doing that just right: 

~~~ python
3 / 2 == 1.5
3 // 2 == 1
~~~

http://python-reference.readthedocs.io/en/latest/docs/operators/floor_division.html

I don't know if it's too much of a breaking change though? Maybe for Ruby3x3?

Thanks.



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