Reading a lesson book, I was testing this simple scala 2.12
code :
var b:ArrayBuffer[Int] = new ArrayBuffer();
b.append(5);
b += (8, 3, 2);
for(i <- 0 to 3 reverse)
println(b(i));
But I've received the error message :
import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
Of course, I did the wanted import then, and it worked :
import scala.language.postfixOps
2
3
8
5
But what is that notion of language keywords unlocked by an import?
Implicitly, I've checked that the for
keyword is immediately available in Scala,
and I assume that while
and most others are too,
but if reverse
and some others aren't, it means that there is a list of...
disabled keywords (???)
But I don't know that list, and the reason why they are some that must be explicitly activated.
- Are they of discouraged use ?
- Are they deprecated ?
- Or in an "early preview" state, intended to be really implemented in
Scala 2.13
or later, and considered unstable ?