[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
Issue #12134 has been updated by Martin D端rst.
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74610] [Ruby trunk Feature#12133] Ability to exclude start when defining a range
From:
naruse@...
Date:
2016-03-27 16:57:10 UTC
List:
ruby-core #74610
Issue #12133 has been updated by Yui NARUSE.
Ryan Hosford wrote:
> Here you've used the case statement to exclude start on the middle range. The problem is the code is largely static while the values of the endpoints (and which ranges should include those endpoints) may change. Physicians may all agree that 20.1 is in a low range today, but tomorrow?
>
> I think this workaround could be made to work ( if 'middle' range is exclude start, 'low' needs `#..`; if 'middle' range is not exclude start, 'low' needs `#...`) but it would be tricky, unintuitive, complicated, etc..
What I want to ask is "Is the range extension really helps developers?".
I can implement the same behavior with separating data and code like following:
```ruby
x = 23.5r
ranges = [(0..20.1r), (20.1...23.4r), (23.4r..99)]
values = %w[low middle high]
idx = ranges.index{|range|range.include?(x)}
puts values[idx]
```
Does the new feature enables more clear code?
----------------------------------------
Feature #12133: Ability to exclude start when defining a range
https://bugs.ruby-lang.org/issues/12133#change-57737
* 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>