-----Messaggio originale----- Da: Konda R. [mailto:kondarao77 / yahoo.com] Inviato: gioved10 novembre 2011 21:36 A: ruby-talk ML Oggetto: sum returning two values Hi, Can you please help me on this issue, I have seen your mail id from ruby forum. I am using ruby program for summing up all the numbers from array. Unfortunately it is returning two values instead of one value.?? Can you please help me on this.... I appreciate your help on this..:) Input to array: 9989 9991 19980 -> it summing above two numbers 9990 9989 19979 -> it is summing these two numbers all 4 numbers shoud add and retunr one value but , my ruby program returning two values saparately(19980 ,19979 ) sum.rb code ---- module Enumerable # sum of an array of numbers def sum return self.inject(0){|acc,i|acc +i} end end # module Enumerable numbers = [] print "\n" ARGV.each { |num| i = Float(num) numbers << i } #n=numbers.sum.to_i #print n.to_s.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2') print numbers.sum.to_i #print "\n" ---Delete ReplyReply ForwardMove -- Posted via http://www.ruby-forum.com/. -- Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Capodanno al parco Oltremare Riccione: Pacchetto hotel 3 stelle in centro + ingresso al parco. * Mezza pensione, Internet gratis, animazione per bimbi. Scopri l'offerta! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid980&d)-12