The reason is because `var` means it will be modified. If it's passed in like
that how are you supposed to "retrieve" the modification
Thanks… mystery solved…
As to why the compiler doesn’t realize it is being passed into a proc requiring
a _var_ and accommodating is interesting.
See `sugar.dup`
@aEverr is correct. The actual error here is that `toHeapQueue` requires a
variable (something it can modify, so a `let` won't work, only `var`).
Unfortunately values that you only pass in to a procedure aren't considered
variable by the Nim compiler for some reason. So you have to first assign
in the first lastStoneWeight, `proc lastStoneWeight(stones: var Stones): int`,
it requires a var.
`var stones = weights.mapIt(Stone(weight: it)).toHeapQueue` makes a var or a
variable to a mutable value, okay, and you pass it. `result =
lastStoneWeight(stones)`
but here,
Probably very simplebut stumps me :-(
Any explanation would be appreciated...
* * *
Why is line 25:
lastStoneWeight(weights.mapIt(Stone(weight: it)).toHeapQueue)
Run
not equivalent to commented out lines at 23-24:
var stones =