#Replacing ** syntax with @splat

1 messages · Page 1 of 1 (latest)

sonic hemlock
#

whats the equivalent of this in master branch of zig?

    var members = [1]?gir.Member{null} ** 64;

i tried it but not worked:

    var members: [64]?gir.Member = @splat(0);
src/translate.zig:1044:43: error: expected type '?gir.Member', found 'comptime_int'
    var members: [64]?gir.Member = @splat(0);

Related:
https://github.com/ziglang/zig/issues/24738
https://codeberg.org/ziglang/zig/pulls/32130

I'm new in Zig. so i even dont know what is @splat for.

Zig v0.17.0-dev.1099+7db2ef610 (master)

GitHub

The main use case for a ** b syntax was initializing arrays. We now have @splat for that. The repeated-pattern use case is rare enough that it does not need to be syntax.

gilded meteor
#

@splat(null)

sonic hemlock
#

hmm thanks it worked

fast zenith
#

it’s because you put a 0 instead of a gir.Member

#

since it’s optional it can also be null