From: Artem Voroztsov Date: 2008-03-13T20:19:14+09:00 Subject: Enumerator in ruby 1.9. # One could write module Enumerable def sum inject(0) {|f,x| f+x} end end # And we have puts [1,2,3,4].sum # => 10 # But it works only for numbers. # I would like to write more general code: module Enumerable def sum each.skip_first.inject(first) {|f,x| f+x} end end # so we have: puts [1,2,3,4].sum #=> 10 puts ['a','b','c'].sum #=> 'abc' ------------------------ 1) Is it a good idea to add method ''first' to Enumerable? 2) Please, show me the _right_ code for Enumerator#skip_first(n=1) (ruby1.9) Thanks!