#Noob question

1 messages · Page 1 of 1 (latest)

torpid totem
#

Im trying to make a simple function:

pub fn foo(value: i32) i32 {
    for (values, 0..) |int, index| {
        if (value < int) return index;
    }
}

However the compiler complains:

day-01.zig:7:16: error: expected ')', found ','
    for (values, 0..) |int, index| {
               ^      

I'm super new to Zig, did I missunderstand something?

misty ruin
#

Those type of for-loops were implemented fairly recently, your compiler is most likely too old

primal plaza
#

looks like you're using zig 0.10.x

misty ruin
#

The range (0..) feature that is

torpid totem
misty ruin
#

I recommend using the correct documentation version that matches the compiler's

torpid totem
#

can I update my zig to master?

#

I installed with choco

#

in windwos

misty ruin
#

I have no experience with choco, sorry

#

You can always download the latest version from the website and use that instead