Project

General

Profile

Actions

Feature #12133

closed

Ability to exclude start when defining a range

Added by slash_nick (Ryan Hosford) over 8 years ago. Updated over 3 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:74086]

Description

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.

Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0