Project

General

Profile

Actions

Feature #16894

open

Integer division for Ruby 3

Added by ankane (Andrew Kane) over 4 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:98371]

Description

Hi Ruby team,

It'd be great if division in Ruby matched what we all learned in school.

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.


Files

integer division.png (14.3 KB) integer division.png NuriYuri (Youri Nouri), 05/15/2020 05:37 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0