Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby hash with default value

hash = { foo: 'bar' }
hash.default = :default_value
hash[:foo] #=> 'bar'
hash[:inexistent] #=> :default_value
 
PREVIOUS NEXT
Tagged: #ruby #hash #default
ADD COMMENT
Topic
Name
5+1 =