ruby-changes:59455
From: zverok <ko1@a...>
Date: Tue, 24 Dec 2019 23:58:12 +0900 (JST)
Subject: [ruby-changes:59455] f2e1e6cba4 (master): Enhance explanations for beginless range and #clamp, and add missing feature
https://git.ruby-lang.org/ruby.git/commit/?id=f2e1e6cba4 From f2e1e6cba451375d8eb839bf2e7c9a39bccc044c Mon Sep 17 00:00:00 2001 From: zverok <zverok.offline@g...> Date: Sat, 21 Dec 2019 23:23:20 +0200 Subject: Enhance explanations for beginless range and #clamp, and add missing feature diff --git a/NEWS b/NEWS index 4ebe7f0..c34ffae 100644 --- a/NEWS +++ b/NEWS @@ -161,10 +161,19 @@ sufficient information, see the ChangeLog file or Redmine https://github.com/ruby/ruby/blob/trunk/NEWS#L161 ==== Other miscellaneous changes -* A beginless range is experimentally introduced. It might not be as useful - as an endless range, but would be good for DSL purposes. [Feature #14799] +* A beginless range is experimentally introduced. It might be useful + in +case+, new call-sequence of the <code>Comparable#clamp</code>, + constants and DSLs. [Feature #14799] ary[..3] # identical to ary[0..3] + + case RUBY_VERSION + when ..."2.4" then puts "EOL" + # ... + end + + age.clamp(..100) + where(sales: ..100) * Setting <code>$;</code> to a non-nil value is warned now. @@ -246,6 +255,10 @@ Comparable:: https://github.com/ruby/ruby/blob/trunk/NEWS#L255 -1.clamp(0..2) #=> 0 1.clamp(0..2) #=> 1 3.clamp(0..2) #=> 2 + # With beginless and endless ranges: + -1.clamp(0..) #=> 0 + 3.clamp(..2) #=> 2 + Complex:: @@ -414,6 +427,12 @@ Range:: https://github.com/ruby/ruby/blob/trunk/NEWS#L427 * Added Range#minmax, with a faster implementation than Enumerable#minmax. It returns a maximum that now corresponds to Range#max. [Bug #15807] + Modified method:: + + * Range#=== now uses #cover? for String arguments, too (in Ruby 2.6, it was + changed from #include? for all types except strings). [Bug #15449] + + RubyVM:: Removed method:: -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/