Count Values in an Array
class Array def total t = 0 self.each { |v| t += v } t end end
Use it like this:
[1,2,2,3].total # => 8
12111 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
class Array def total t = 0 self.each { |v| t += v } t end end
[1,2,2,3].total # => 8