Ruby Tips

inject

Combines the elements of enum by applying the block to an accumulator value (memo) and each element in turn

(5..10).inject {|sum, n| sum + n }              #=> 45

Ruby Tips - a simple ruby tip generator RubyTips.dev

Refresh the page to generate a new tip. Or just click here

Built by @zayneabraham

RubyTips - A random Ruby tip generator | Product Hunt Embed