[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
SXNzdWUgIzEyMTM0IGhhcyBiZWVuIHVwZGF0ZWQgYnkgTWFydGluIETDvHJzdC4KCgpUc3V5b3No
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:74587] [Ruby trunk Feature#12133] Ability to exclude start when defining a range
From:
naruse@...
Date:
2016-03-26 13:38:27 UTC
List:
ruby-core #74587
Issue #12133 has been updated by Yui NARUSE. Ryan Hosford wrote: > I think this is useful because it would give the ruby language a more complete implementation of ranges/intervals. I recently built a feature that requires me to cover the range from **a** to **b** with 2 to 5 sub-ranges, validating that there are no gaps and no overlaps in the sub-ranges. I also needed to be flexible with choosing into which sub-range an endpoint should fall. Examples: If your systolic blood pressure is 120 mmHg, do I say you are in a normal range or do I say you have Prehypertension? If your HBA1C is 6.5%, are you in a pre-diabetic condition or do you have diabetes? On such case, an implementation will be something like following. If you want more easy to read one, which declares inclusive-or-exclusive range and validates there's no duplication, it seems something different one from current simple range object, but more complex one. ```ruby case ARGV.shift.to_r when 0..20.1.to_r puts "low" when 20.1.to_r...23.4.to_r puts "middle" when 23.4.to_r..99 puts "high" end ``` ---------------------------------------- Feature #12133: Ability to exclude start when defining a range https://bugs.ruby-lang.org/issues/12133#change-57716 * 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:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>