From 51215937874dd5e8705701c772b41a7ce522f67c Mon Sep 17 00:00:00 2001 From: tinogomes Date: Wed, 8 Jan 2014 15:46:42 -0200 Subject: Adding Hash#compact and Hash#compact! methods * Adding Hash#compact and Hash#compact! methods * Using Ruby 1.9 syntax on documentation * Updating guides for `Hash#compact` and `Hash#compact!` methods * Updating CHANGELOG for ActiveSupport * Removing unecessary protected method and lambda for `Hash#compact` implementations * Performing `Hash#compact` implementation - https://gist.github.com/tinogomes/8332883 * fixing order position * Fixing typo --- guides/source/active_support_core_extensions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 1a43bd206e..59dfefd22f 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -2907,6 +2907,16 @@ The method `with_indifferent_access` returns an `ActiveSupport::HashWithIndiffer NOTE: Defined in `active_support/core_ext/hash/indifferent_access.rb`. +### Compacting + +The methods `compact` and `compact!` return a Hash without items with `nil` value. + +```ruby +{a: 1, b: 2, c: nil}.compact # => {a: 1, b: 2} +``` + +NOTE: Defined in `active_support/core_ext/hash/compact.rb`. + Extensions to `Regexp` ---------------------- -- cgit v1.2.3