#Initialising array with struct

1 messages · Page 1 of 1 (latest)

woeful basin
#

seems like an inconsistency as [_]u8{1, 2, 3} works

#
pub const attributeQuestions = ([_]AttributeQuestion){
    .{
        .optionA = "a",
        .optionB = "b",
    }
};```
this doesnt work either, not sure how () effect types
hidden cosmos
#

what about it doesnt work?

woeful basin
#

actually, changing _ to a number works

woeful basin
hidden cosmos
#

it should

woeful basin
#

this doest work because it treats it as [?](MyStruct{}) instead of ([?]MyStruct){}

marble hazel
#

length inferrence for arrays is special syntax, you can't wrap the type in parens

woeful basin
#

it seems to work

#

oh, i see.

woeful basin
#

MyStruct{} is read before [_]MyStruct

marble hazel
#

([_]Foo){} does not work (at least it shouldn't...), [_]Foo{} works

woeful basin
#

oh it does work.

#

zls is confusing me, my bad