Hi,
I've got a background in Rust (10 years) and in Python (1 year) and I try to learn Mojo.
I've try this :
fn main():
try:
var stuff = String("dddd\nffff\njjjj\nkkkk").split("\n")
for x in stuff:
print(x)
except:
print("failed")
and got this obscure error message :
/source/prog.mojo:7:12: error: no matching function in call to 'print'
print(x)
~~~~~^~~
/source/prog.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
fn main():
^
/source/prog.mojo:1:1: note: candidate not viable: callee expects 2 parameters, but 0 were specified
fn main():
^
/source/prog.mojo:7:13: note: failed to infer parameter 'T', argument type 'Reference[String, 1, stuff, 0]' does not conform to trait 'Stringable'
print(x)
^
mojo: error: failed to parse the provided Mojo source module
but if I use indexes, it works :
for x in range(0, len(stuff)):
print(stuff[x])
I seem to have a hard time with the most basic things 🙂
What have I misunderstood ?
Thanks