lib/straightedge/extend/array.rb in straightedge-0.1.1 vs lib/straightedge/extend/array.rb in straightedge-0.1.2
- old
+ new
@@ -1,10 +1,17 @@
class Array
include Straightedge::Aspects::Positional
include Straightedge::Aspects::Figural
- def sum
- inject(&:+)
+ def second; self[1] end
+ def third; self[2] end
+
+ def sum(&blk)
+ if block_given?
+ map(&blk).sum
+ else
+ inject(&:+)
+ end
end
def mean
sum / size
end