I can't seem to access the local
scope within my ListEach:
writeDump(local.woCoreID); // outputs expected values
// LOOP OVER LIST AND SEPARATE TEXT FROM INTEGERS
ListEach(local.__userSuppliedWorkoutTagList, function (item) {
writeDump(item) // outputs expected values
writeDump(local.woCoreID); // key [woCoreID] doesn't exist
});
when I try to access the local.woCoreID, I get an error message, key [woCoreID] doesn't exist
. Why is that when I can dump it before the ListEach and I see the value is there. What am I missing here?
I'm using Lucee 5.x
Each function
has its own local
scope. If you want to the outer scope, you must make a reference to it:
var outerLocal = local;
ListEach(local.__userSuppliedWorkoutTagList, function (item) {
writeDump(item);
writeDump(outerLocal.woCoreID);
});
or use a regular, counted for
loop instead of ListEach()
+ function
.
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