Ranges
a..b includes b, a...b excludes it. Use to_a, include?, step and each.
Example
r = (1..5)
puts r.to_a.inspect, (1...5).to_a.inspect, r.include?(3), r.sum
puts ("a".."e").to_a.join, (1..10).step(3).to_a.inspectResult
[1, 2, 3, 4, 5] [1, 2, 3, 4] true 15 abcde [1, 4, 7, 10]
Exercise
Exclude the end.
15
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.