Inclusive Range Expressions
This is little more than a footnote, but a potentially useful one. We’ve so far seen for i in 1..11
to mean “iterate the numbers starting with 1 and ending just before 11.” That’s what we call an exclusive range since it excludes the final value (11) from being iterated. There’s also something called an inclusive range, that looks like this:
for i in 1..=10
That =
converts the range into something inclusive, and has the exact same meaning as 1..11
. Which one you use depends on your personal preference. You’ll end up seeing both in the wild, so it’s worth being aware of both of them.