Hi, > [1, 2, 3].apply('+'.intern) # => 6 > [2, 3, 4].apply('*'.intern) # => 24 you mean something like this? # = begin ================================================================ class Array # Taken from PRR (I'm still using 1.6.7) def inject(n) each { |value| n = yield(n, value) } n end # Apply func def apply(op) return nil if self.empty? self[1..-1].inject(self[0]) { |n, v| n.method(op).call(v) } end # Apply func without inject ... def apply_ni(op) n = self[0] self[1..-1].each { |x| n = n.method(op).call(x) } unless \ self.size <= 1 n end end puts ([].apply('+'.intern)) # => nil puts ([1].apply('+'.intern)) # => 1 puts ([1, 2, 3].apply('+'.intern)) # => 6 puts ([2, 3, 4].apply('*'.intern)) # => 24 puts (["abc", "def"].apply('+'.intern)) # => abcdef # = end ================================================================ Sincerely, W. -- Wejn <lists+rubytalk(at)box.cz> (svamberk.net's Linux section, fi.muni.cz student, linuxfan) >>> Bored? Want hours of entertainment? <<< >>> Just set the initdefault to 6! <<<