Range - sum
- An example using a range and sum together in a one-line statement.
res = (0..3).sum { |ix| ix * ix }
puts res
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
res = (0..3).sum { |ix| ix * ix }
puts res