Let's say I have a procedure getTuple(): (int, int, int)
. How do I iterate over the returned tuple? It doesn't look like items
is defined for tuple
, so I can't do for i in getTuple()
.
I initially had this returning a sequence
, which proved to be a bottleneck. Can I get this to work without affecting performance? I guess as a last resort I could unroll my loop, but is there any way around that?
OK, I figured this out. You can iterate over the tuple's fields:
let t = (2,4,6)
for x in t.fields:
echo(x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With