instance method
default
Ruby on Rails 8.0.4
Since v3.0.20Signature
default(key = (no_key = true))
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'
Parameters
-
keyopt = (no_key = true)
Source
# 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
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 223
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess