diff options
author | utilum <oz@utilum.com> | 2018-05-21 23:53:38 +0200 |
---|---|---|
committer | utilum <oz@utilum.com> | 2018-05-22 15:56:36 +0200 |
commit | e04a79e772fc9d016d73138c3f322212f3b6ead7 (patch) | |
tree | ff8e99281546467b2fbb230c810d4f8e83670445 | |
parent | 0fcb921a65e615c301450d7820b03473acd53898 (diff) | |
download | rails-e04a79e772fc9d016d73138c3f322212f3b6ead7.tar.gz rails-e04a79e772fc9d016d73138c3f322212f3b6ead7.tar.bz2 rails-e04a79e772fc9d016d73138c3f322212f3b6ead7.zip |
add CHANGELOG/Doc
-rw-r--r-- | activesupport/CHANGELOG.md | 11 | ||||
-rw-r--r-- | guides/source/active_support_core_extensions.md | 19 |
2 files changed, 23 insertions, 7 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index a384fc3bd2..91818c3112 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,14 @@ +* Allow Range#=== and Range#cover? on Range + + `Range#cover?` can now accept a range argument like `Range#include?` and + `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved + into a new file, with these two methods. + + *Requiring active_support/core_ext/range/include_range is now deprecated.* + *Use `require "active_support/core_ext/range/compare_range"` instead.* + + *utilum* + * Add `index_with` to Enumerable. Allows creating a hash from an enumerable with the value from a passed block diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index cde217e1e4..057651e0cf 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -2889,9 +2889,9 @@ As the example depicts, the `:db` format generates a `BETWEEN` SQL clause. That NOTE: Defined in `active_support/core_ext/range/conversions.rb`. -### `include?` +### `===`, `include?`, and `cover?` -The methods `Range#include?` and `Range#===` say whether some value falls between the ends of a given instance: +The methods `Range#===`, `Range#include?`, and `Range#cover?` say whether some value falls between the ends of a given instance: ```ruby (2..3).include?(Math::E) # => true @@ -2900,18 +2900,23 @@ The methods `Range#include?` and `Range#===` say whether some value falls betwee Active Support extends these methods so that the argument may be another range in turn. In that case we test whether the ends of the argument range belong to the receiver themselves: ```ruby +(1..10) === (3..7) # => true +(1..10) === (0..7) # => false +(1..10) === (3..11) # => false +(1...9) === (3..9) # => false + (1..10).include?(3..7) # => true (1..10).include?(0..7) # => false (1..10).include?(3..11) # => false (1...9).include?(3..9) # => false -(1..10) === (3..7) # => true -(1..10) === (0..7) # => false -(1..10) === (3..11) # => false -(1...9) === (3..9) # => false +(1..10).cover?(3..7) # => true +(1..10).cover?(0..7) # => false +(1..10).cover?(3..11) # => false +(1...9).cover?(3..9) # => false ``` -NOTE: Defined in `active_support/core_ext/range/include_range.rb`. +NOTE: Defined in `active_support/core_ext/range/compare_range.rb`. ### `overlaps?` |