Sonic Pi's (range 0, 8) excludes the end value (0..7) while (line 0, 8, steps: 9) includes it — a common off-by-one source
Sonic Pi’s range and line generators differ on whether the endpoint is included. (range 0, 8) produces 0,1,2,3,4,5,6,7 — the end value 8 is excluded, matching Ruby’s half-open range convention. (line 0, 8, steps: 9) divides the interval into steps and does include both endpoints. Assuming range is inclusive is a frequent off-by-one bug, producing a sequence one element shorter than expected or missing the top value. When you need the endpoint, use line with an explicit step count, or extend the range bound by one.
Examples
(range 0, 8) → 0,1,2,3,4,5,6,7 (8 excluded). (line 0, 8, steps: 9) → 0,1,2,…,8 (8 included).
Assessment
Predict the elements of (range 0, 4) and explain how to generate 0 through 4 inclusive using line.