Lots of Array methods


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # use Array#inject to calculate totals
  2.  
  3. def number_of_incomings
  4. assets.inject(0) {|total, asset| total += asset.incomings.size }
  5. end

URL: http://www.therailsway.com/2007/1/10/assetsgraphed-part-2

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.