Simple scala question. Consider the below.
scala> var mycounter: Int = 0; mycounter: Int = 0 scala> mycounter += 1 scala> mycounter res1: Int = 1
Sometimes I do this:
val nextId = { var i = 0; () => { i += 1; i} } println(nextId()) //> 1 println(nextId()) //> 2
Might not work for you if you need sometime to access the value without incrementing.