var set = TreeSet(5,4,3,2,1) println(set) val diffSet: TreeSet[Int] = set // if I change above code to val diffSet: Set[Int] = set // the result is
You can do:
scala> for (i <-genSet.view; x = i + 1) println(x) 2 3 4 5 6
Although, it's the type of trick that when you look at it after a few months, you may wonder why you added .view ...
.view