MyriadColors
Explore posts from serversMModular
•Created by MyriadColors on 5/15/2024 in #questions
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.
4 replies
MModular
•Created by MyriadColors on 5/15/2024 in #questions
How to take user input form the terminal?
Self-explanatory, the best I could find with research was:
I got this error:
What is your name? pedro
Unhandled exception caught during execution: 'str' object has no attribute 'to_string'
mojo: error: execution exited with a non-zero result: 1
So my questions:
1. How can I do it?
Thank you.
31 replies