instance method
default
Ruby on Rails 5.2.8.1
Since v3.0.20Signature
default(*args)
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
-
argsrest
Source
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 219
def default(*args)
super(*args.map { |arg| convert_key(arg) })
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 219
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess