Reassign Variables

Support for reassigning variables:

let aVariable;

aVariable = newValue;

This makes writing more complex functions a lot easier.

You can redeclare a variable with the same name, which might be good enough for your usecase.

let aVariable = "a"
let aVariable = newValue

If you have a specific usecase that this wouldn’t work for let me know

Yes, and no.

With the current limitations in Fauna you’re right that redefining instead of reassigning is doing the job with the current constraints in Fauna. But at the same time I’m hoping that this Javascript behavior will work in the future(and then I need reassigning instead of redefining):

let aVariable = "Hello"

  aVariable = "Bye"
  // Throwing an error because FQL expects a return statement inside an if statement

aVariable // Never reached in FQL if the "if" condition got triggered.

You can refactor that to

let aVariable = "Hello"

let aVariable = if(true){

// now equals "Bye"

Hi folks - Thanks for this request. Mutable variables are on our roadmap, although my expectation is that we’ll not implement them in the next 90 days.