MΓ³dulo 02 Β· Collections & Blocks β LecciΓ³n 6 de 6 Β· ~8 min
Ranges & capstone
1..5 vs 1...5 β inclusive vs. exclusive
A range is a compact way to describe "every value from here to there." Two dots include the end; three dots exclude it:
(1..5).to_a # [1, 2, 3, 4, 5] β end INCLUDED (1...5).to_a # [1, 2, 3, 4] β end EXCLUDED
.to_a turns a range into a real array. Ranges aren't just for numbers, either β to_a is just the easiest way to see one's contents while you're learning.