mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-03-28 21:34:52 +00:00
emphasize that the end number of a for-loop range is exclusive
This commit is contained in:
parent
3ecaa34271
commit
9fb6d21ce6
|
|
@ -28,6 +28,8 @@
|
|||
// 0..10 is a range from 0 to 9
|
||||
// 1..4 is a range from 1 to 3
|
||||
//
|
||||
// Crucially, the end value is EXCLUSIVE.
|
||||
//
|
||||
// At the moment, ranges in loops are only supported in 'for' loops.
|
||||
//
|
||||
// Perhaps you recall Exercise 13? We were printing a numeric
|
||||
|
|
@ -64,6 +66,12 @@ pub fn main() void {
|
|||
}
|
||||
|
||||
std.debug.print("\n", .{});
|
||||
|
||||
// Let's also print every number from 1 through 15
|
||||
for (???) |n| {
|
||||
std.debug.print("{} ", .{n});
|
||||
}
|
||||
std.debug.print("\n", .{});
|
||||
}
|
||||
//
|
||||
// That's a bit nicer, right?
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user