/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#Set up the hours array hours = [8, 8, 8, 8] #Run the inject method on the Array total_hours = hours.inject {|result, element| result + element} #Output total hours puts total_hours #=> 32
URL: http://blog.jayfields.com/2008/03/ruby-inject.html
Comments
