From: eregontp@... Date: 2016-03-25T22:12:15+00:00 Subject: [ruby-core:74582] [Ruby trunk Feature#12133] Ability to exclude start when defining a range Issue #12133 has been updated by Benoit Daloze. On Fri, Mar 25, 2016 at 9:58 PM, Matthew Kerwin wrote: > > That's only true for ranges of discrete values. A range like: `(0.0..1.0).exclude_first` would look absolutely horrible as `0.0.next_float..1.0`, and I don't think there's even an equivalent for Rationals or Times. Ah right, in the case a Range is used mostly for #include? and co, then .next is not really a good fix. Please disregard my comment then. Maybe Range should use another method for iterating over values so it would behave more consistently. ---------------------------------------- Feature #12133: Ability to exclude start when defining a range https://bugs.ruby-lang.org/issues/12133#change-57712 * Author: Ryan Hosford * Status: Feedback * Priority: Normal * Assignee: ---------------------------------------- An intuitive, approach would be to allow defining ranges like so: ~~~ [1..10] [1..10) (1..10] (1..10) ~~~ ... where a square bracket indicates boundary inclusion and a parenthesis represents boundary exclusion. The syntax there is obviously not going to work, but it demonstrates the idea. A more feasible, still intuitive, solution might look like the following ~~~ (1..10) # [1..10] (1...10) # [1..10) ... Alternatively: (1..10).exclude_end (1..10).exclude_start # (1..10] (1...10).exclude_start # (1..10) ... Alternatively: (1..10).exclude_start.exclude_end ~~~ For consistency, I think we'd also want to add `#exclude_start?` & `#exclude_end` methods. -- https://bugs.ruby-lang.org/ Unsubscribe: