Question about iterating a list of strings
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 :
and got this obscure error message :
but if I use indexes, it works :
I seem to have a hard time with the most basic things 🙂
What have I misunderstood ?
Thanks
8 Replies
You need to use print(x[])
for 'dereference' or something like that. I've seen it in the other code, but still don't understand this model yet by myself)
thanks !
Auto-deref has been implemented and will slowly get added to the stdlib so you wouldn't need to deference pointers yourself in the future
@FSaez good to know, thanks.
Yes. There’s a plan for auto dereferencing. @FSaez You should open an issue for a wrong or unhelpful error message
I was wondering, any particular reason to use [] operator to deference, instead of widly-accepted *, present in mainstream languages? I understand the "access to value" meaning of [], close to array[index], but asterisk is so familiar to programmers...
"*" is already heavily overloaded in Python
Also, the square bracket acts as a getter.
I believe ref[] is the same as ref[0] or something like that
yes, the getter meaning is what I called "access to value". But * overloading is indeed a very valid explanation. thx