default

hsh.default(key=nil) รข obj
Instance Public methods

Returns the default value, the value that would be returned by hsh if key did not exist in hsh. See also Hash::new and Hash#default=.

h = Hash.new                            #=> {}
h.default                               #=> nil
h.default(2)                            #=> nil

h = Hash.new("cat")                     #=> {}
h.default                               #=> "cat"
h.default(2)                            #=> "cat"

h = Hash.new {|h,k| h[k] = k.to_i*10}   #=> {}
h.default                               #=> nil
h.default(2)                            #=> 20
doc_ruby_on_rails
2015-04-11 22:08:10
Comments
Leave a Comment

Please login to continue.