How to initialize an empty List[String]
What Im trying to do:
Problem: when compiling:
/home/pedrot/Desktop/Coding/mojo/learn/main.mojo:25:24: error: use of uninitialized value 'args'
args.append(user_input[i])
^
/home/pedrot/Desktop/Coding/mojo/learn/main.mojo:19:5: note: 'args' declared here
var args: List[String]
^
mojo: error: failed to run the pass manager
But when I try:
It also complains:
/home/pedrot/Desktop/Coding/mojo/learn/main.mojo:19:30: error: cannot implicitly convert 'ListLiteral[]' value to 'List[String]' in 'var' initializer
var args: List[String] = []
^~
mojo: error: failed to parse the provided Mojo source module
THank you.
1 Reply
var args = List[String]()