You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see a function 'expand_to_tuple' that can convert a struct or an array by returning multiple values.
But is there a way to create a true tuple (or an anonymous struct)?
I am making up syntax here, but something like:
my_tuple := (1, "foo", 2.0)
which would create a tuple (anonymous struct) of (i32, string, f32) and have the ability to get /set each value:
x := my_tuple[0]
y := my_tuple[1]
z := my_tuple[2]
The following works:
Foo :: struct {
x: int,
y: string,
z: f32,
}
blah := Foo{137, "string", 1.0};
x, y, z := expand_to_tuple(blah);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How are tuples supported in Odin at the moment?
I see a function 'expand_to_tuple' that can convert a struct or an array by returning multiple values.
But is there a way to create a true tuple (or an anonymous struct)?
I am making up syntax here, but something like:
my_tuple := (1, "foo", 2.0)
which would create a tuple (anonymous struct) of (i32, string, f32) and have the ability to get /set each value:
x := my_tuple[0]
y := my_tuple[1]
z := my_tuple[2]
The following works:
Foo :: struct {
x: int,
y: string,
z: f32,
}
blah := Foo{137, "string", 1.0};
x, y, z := expand_to_tuple(blah);
Beta Was this translation helpful? Give feedback.
All reactions