How do I add only the positive numbers in a ruby array?

后端 未结 0 776
悲&欢浪女
悲&欢浪女 2021-01-18 23:23

I\'m new to ruby and I\'m trying to make a method that gets the sum of all the positive numbers any array of numbers. Here is an example:

arr=(1,3,-1,7,4,-9,0         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题