aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJon Moss <maclover7@users.noreply.github.com>2016-05-24 18:57:26 -0400
committerJon Moss <maclover7@users.noreply.github.com>2016-05-24 18:57:26 -0400
commitbf219714dce494f5b69cb7dd9b8c43a68a4988da (patch)
treecaad49072c3de87f4cae390d8a37796af026713b /activesupport
parent3ac9956bfc8603cdd9999edeec15219dff02d8a2 (diff)
parentbe1b716d77216449438af094170d4b0f61739cda (diff)
downloadrails-bf219714dce494f5b69cb7dd9b8c43a68a4988da.tar.gz
rails-bf219714dce494f5b69cb7dd9b8c43a68a4988da.tar.bz2
rails-bf219714dce494f5b69cb7dd9b8c43a68a4988da.zip
Merge pull request #25134 from malept/consistent-hash-examples
Normalize whitespace for Hash#compact documentation
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/compact.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/compact.rb b/activesupport/lib/active_support/core_ext/hash/compact.rb
index 5dc9a05ec7..62ea579c65 100644
--- a/activesupport/lib/active_support/core_ext/hash/compact.rb
+++ b/activesupport/lib/active_support/core_ext/hash/compact.rb
@@ -1,9 +1,9 @@
class Hash
# Returns a hash with non +nil+ values.
#
- # hash = { a: true, b: false, c: nil}
- # hash.compact # => { a: true, b: false}
- # hash # => { a: true, b: false, c: nil}
+ # hash = { a: true, b: false, c: nil }
+ # hash.compact # => { a: true, b: false }
+ # hash # => { a: true, b: false, c: nil }
# { c: nil }.compact # => {}
def compact
self.select { |_, value| !value.nil? }
@@ -11,9 +11,9 @@ class Hash
# Replaces current hash with non +nil+ values.
#
- # hash = { a: true, b: false, c: nil}
- # hash.compact! # => { a: true, b: false}
- # hash # => { a: true, b: false}
+ # hash = { a: true, b: false, c: nil }
+ # hash.compact! # => { a: true, b: false }
+ # hash # => { a: true, b: false }
def compact!
self.reject! { |_, value| value.nil? }
end