This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Array.sum (from ruby core) --- array.sum(init = 0) -> object array.sum(init = 0) {|element| ... } -> object --- When no block is given, returns the object equivalent to: sum = init array.each {|element| sum += element } sum For example, `[e1, e2, e3].sum` returns `init + e1 + e2 + e3`. Examples: a = [0, 1, 2, 3] a.sum # => 6 a.sum(100) # => 106 The elements need not be numeric, but must be `+`-compatible with each other and with `init`: a = ['abc', 'def', 'ghi'] a.sum('jkl') # => "jklabcdefghi" When a block is given, it is called with each element and the block's return value (instead of the element itself) is used as the addend: a = ['zero', 1, :two] s = a.sum('Coerced and concatenated: ') {|element| element.to_s } s # => "Coerced and concatenated: zero1two" Notes: * Array#join and Array#flatten may be faster than Array#sum for an Array of Strings or an Array of Arrays. * Array#sum method may not respect method redefinition of "+" methods such as Integer#+.
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.