question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

for...in doesn't seem to execute the body

See original GitHub issue

Executing the following program:

ask {
    let mySum:float = 0
    for(let index in itemPrices) {
        const price = itemPrices:at(index)
        mySum = mySum:plus(price)
    }
    mySum
}

should lead to an error as itemPrices does not exist and is not defined as resource or value either. Instead, this program returns 0.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
czerwinskilukasz1commented, Jun 30, 2020

Following our chat, this is how it should work for a string:

const word = 'Hello';
for(const index in word) {
 log(index);
}
0reactions
mhagmajercommented, Jun 26, 2020

Same as for-of. This should also work for strings I think

Read more comments on GitHub >

github_iconTop Results From Across the Web

For Loop not executing - Stack Overflow
The body of the loop will only execute when the condition is true. ... The reason the loop doesn't execute is mentioned by...
Read more >
Loops: while and for - The Modern JavaScript Tutorial
Executes once upon entering the loop. condition, i < 3, Checked before every loop iteration. If false, the loop stops. body, alert( ...
Read more >
Loops: while(), for() and do .. while() - Physics and Astronomy
If the condition is false the body of the loop never executes at all. ... sense while() loops are a bit more complicated...
Read more >
4. Conditionals and loops — Beginning Python Programming ...
Each item in turn is (re-)assigned to the loop variable, and the body of the loop is executed. The general form of a...
Read more >
Loops in JavaScript - performing repeated operations on a ...
These loops execute the loop's body (the block) for as long as the condition remains truthy. We use the term one iteration to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found