language · keyword ·
from
Start a numeric range
Use a range when you need an index or a predictable number of iterations.
fromStatus: stable
Positive
Use a range when you need an index or a predictable number of iterations.
cpu · complete-program · type checked
thing point
{
int x
int y
point(int x, int y)
{
this.x = x
this.y = y
}
Sum() -> int
{
return this.x + this.y
}
}
Add(int left, int right) -> int
{
return left + right
}
point value = point(2, 3)
int total = 0
for i from 0 < 4
{
total = total + i
}
int iterations = 0
while iterations < 2
{
iterations = iterations + 1
}
if value.Sum() == 5 and Add(total, iterations) == 8
{
Console.Log("core-edition-ok")
}
else
{
Console.Log("core-edition-failed")
}
project.mech
package = "tests.coreEdition.positive"
Notes and source
< excludes the end; <= includes it.
The step is the next-value expression, such as i + 2.
yeho/parser_loops.cpp parseForStatement; tests/compiler/kyber/range-loop-runtime/start.yh