Le samedi 04 août 2007 à 02:38 +0900, Joshua C. a écrit :
o = a.select {|x| x >= 0}
p = a.inject(0) {|s, x| s += x}
def truc( a, sel, &inj )
o = a.select sel.call
p = a.inject(0) &inj
end
truc( a, proc{|x| x >= 0} ){|s, x| s += x}
Le samedi 04 août 2007 à 02:38 +0900, Joshua C. a écrit :
o = a.select {|x| x >= 0}
p = a.inject(0) {|s, x| s += x}
def truc( a, sel, &inj )
o = a.select sel.call
p = a.inject(0) &inj
end
truc( a, proc{|x| x >= 0} ){|s, x| s += x}
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs