From: marcandre-ruby-core@... Date: 2020-05-15T03:42:34+00:00 Subject: [ruby-core:98373] [Ruby master Feature#16894] Integer division for Ruby 3 Issue #16894 has been updated by marcandre (Marc-Andre Lafortune). Assignee set to matz (Yukihiro Matsumoto) I would bet that a majority of Rubyists would agree that `1/2 == 0` is an unfortunate choice. Either `0.5` or `1/2r` would probably be a better solution. Your proposal has at least two issues. 1) Why `0.5` and not `1/2r` 0) Much more importantly, is it worth the incompatibility. My feeling for 0) is "absolutely not". Notes: a) `mathn` was already redefining `Integer#/` and that was already a source of confusion and issues. b) refinements make it easy for you to redefine `Integer#/` to fit your purposes, and affect only your code and not that of other gems which may rely on `1/2 #=> 0`. I recommend you go that route instead. ---------------------------------------- Feature #16894: Integer division for Ruby 3 https://bugs.ruby-lang.org/issues/16894#change-85641 * Author: ankane (Andrew Kane) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- Hi Ruby team, It'd be great if division in Ruby matched what we all learned in school. ``` ruby 1 / 2 == 0.5 ``` New developers wouldn't immediately be confused when they try to do division and experienced developers could stop adding to_f to their code (typically after they get tripped up on the first run). In my experience, floating point division is way more common than floor division. This could definitely break existing code, so I understand it's a decision that shouldn't be made lightly. Overall, Ruby is really intuitive, but this is one place where it's not. It looks like this was considered for Ruby 2.0 as well as few years ago in #5512, so feel free to close if it's not something you'd like to reconsider right now. -- https://bugs.ruby-lang.org/ Unsubscribe: