Creating numeric variable from an addition

To create an ordinary variable in this do, use let newQuantity = instead of newQuantity <-. In terms of the recent guide, <- “unpacks” the computation, but here there is nothing to unpack.

It would be unwise to automatically discriminate between these two cases for two reasons:

  1. ... <- create productionRecord is still meaningful, regardless of whether you use the productionRecordCid variable afterwards. However, if you never use newQuantity, you can simply eliminate the binding, because you know it is useless if the variable is unused.
  2. It is perfectly meaningful to use let to store Updates, for multiple Update layers to exist, and for it to be unknown whether an expression produces an Update or not. Changing the program in this case would yield “jittery” code, with behavior “snapping” back and forth depending on code elsewhere in the program changing. That would have…bad effects on understanding, to say the least.
1 Like