Array intialization with one element problem #3761
Unanswered
lack-of-gravity-jack
asked this question in
Getting started
Replies: 1 comment
-
The compiler explorer is correct. You can fix your example by writing |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running on compiler explorer https://godbolt.org/ following this tutorial: https://www.youtube.com/watch?v=MMxbP8ME2Ag
package helloworld api;
fn Main() -> i32 {
var arr: [i32;1] = (3);
return 0;
}
I'm getting this error
COMPILATION ERROR: <source>:7: type error in initializer of variable: 'i32' is not implicitly convertible to '[i32; 1]' Compiler returned: 1
If I add another element to the array and change the 1 to a 2, it works
var arr: [i32;2] = (3,3); //works
var arr: auto = (3); //also works
is this a problem with the compiler explorer?
Beta Was this translation helpful? Give feedback.
All reactions