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.

Variable Re-assignment

See original GitHub issue

If I declare a variable and assign an initial value, can I re-assign a different value to it afterwards?

The code below isn’t working:

let var = "test"
$var = "test2"

{
  "variable": $var
}

Error: com.schibsted.spt.data.jslt.JsltException: Parse error: Encountered " "=" "= "" at line 2, column 6.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
larsgacommented, Nov 19, 2021

Yes, JSLT is a functional language. That gives implementations much more freedom, and makes it easier to implement optimizations.

If these loops end up being a performance problem please come back, and we can look at how to deal with that.

0reactions
Psycokwetcommented, Nov 19, 2021

I don’t think it will become an issue, but thank you, I will keep that in mind, and try to adapt to functionnal logic. Thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

5.1 Variable Reassignment and Object Mutation
A variable reassignment is a Python action that assigns a value to a variable that already refers to a value. The most common...
Read more >
2.10. Reassignment — How to Think like a Computer Scientist
A new assignment makes an existing variable refer to a new value (and stop referring to the old value). Save & Run. Original...
Read more >
NCL Variable Assignment / Reassignment
To reassign a variable to something with a different shape or a higher type, you must either use the delete procedure, or the...
Read more >
Introduction to Python Variables and Assignment - AlgoDaily
Values can be reassigned to variables in Python. When variables are reassigned, their value changes to that of the newer value specified, and...
Read more >
Reassignment vs Mutability - DEV Community ‍ ‍
Reassignment consists of assigning a new value for a variable using the = operator. This restriction on the part of const also leads...
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