Method: ActiveSupport::HashWithIndifferentAccess#default
- Defined in:
- activesupport/lib/active_support/hash_with_indifferent_access.rb
#default(key = (no_key = true)) ⇒ Object
Same as Hash#default where the key passed as argument can be either a string or a symbol:
hash = ActiveSupport::HashWithIndifferentAccess.new(1)
hash.default # => 1
hash = ActiveSupport::HashWithIndifferentAccess.new { |hash, key| key }
hash.default # => nil
hash.default('foo') # => 'foo'
hash.default(:foo) # => 'foo'
223 224 225 226 227 228 229 |
# File 'activesupport/lib/active_support/hash_with_indifferent_access.rb', line 223 def default(key = (no_key = true)) if no_key super() else super(convert_key(key)) end end |