ModularM
Modular2y ago
3 replies
TheBeege

What's the proper way to use List?

Anytime I use List, I hit issues with Reference. Looking through docs, I see that Reference is related to unsafe memory operations.

I'm looking into how to avoid variable-length collections using parameters, but I'd like to get this working first, at least. Any ideas?

from collections import List

fn main():
    var my_list: List[Int] = List(1, 2, 3)
    for member in my_list:
        for i in range(member):
            # failed to infer parameter 'type', argument type 'Reference[Int, 1, my_list]' does not conform to trait 'IntableRaising'
            print("counting: " + i)


Edit: I tried adding a var count: Int = member.value in there but to no avail.
Was this page helpful?