2003-08-08 ■ List Ruby Rubyだと、既存のクラスにメソッドやイテレータを追加出来る。 これ、Python で出来ないかなぁ。 class Array def inject(n) each { |v| n = yield(n, v) } n end def sum() inject(0) { |n, v| n + v } end end [1,2,3,4,5, 6, 7, 8, 9, 10].sum 55