Stream: beginners

Topic: ✔ For loops in main


view this post on Zulip Andres Villegas (Jul 11 2026 at 04:21):

I am trying to do a simple for loop in main! how ever, seems that .iter is not resolved only when I try to iterate a list in main. The following fails with:a

MISSING METHOD
This iter method is being called on a value whose type doesn't have that method.

The value's type is:

    List(Builtin.Num.Dec)
main! = |_args| {
    for x in [1, 2, 3] {
        echo!(x.to_str())
    }
    Ok({})
}

doing the same for loop in any other function and calling that function from main seems to work. Is there a restriction on using for loops in main?

view this post on Zulip Andres Villegas (Jul 11 2026 at 04:23):

Sorry, wasn't using latest nightly

view this post on Zulip Notification Bot (Jul 11 2026 at 04:23):

Andres Villegas has marked this topic as resolved.


Last updated: Jul 23 2026 at 13:15 UTC