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:
-
... <- create productionRecord
is still meaningful, regardless of whether you use theproductionRecordCid
variable afterwards. However, if you never usenewQuantity
, you can simply eliminate the binding, because you know it is useless if the variable is unused. - It is perfectly meaningful to use
let
to storeUpdate
s, for multipleUpdate
layers to exist, and for it to be unknown whether an expression produces anUpdate
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.