What is Nostr?
Konrad Rudolph /
npub136d…jsw5
2024-06-15 16:21:43
in reply to nevent1q…mns5

Konrad Rudolph on Nostr: It’s not a bug; it’s a consequence of `for` loops not creating their own scope; ...

It’s not a bug; it’s a consequence of `for` loops not creating their own scope; it’s the same effect you get when writing

for (i in 1 : 10) {}
message(i)

— after the loop, `i` has a single value. Same for `name` in your case. Try `rm(name)` after the loop, before evaluating the active binding. You’ll get an error because `name` no longer exists.

To fix this, create a local scope inside the loop body, assign a local copy of the variabel inside it, and refer to that in your lambda.
Author Public Key
npub136dp8afyynp42gtlhp8wprvuyldmwxdx760w3ynrdvulzfml3t0su2jsw5