I have accepted from many other languages that underscores have as much freedom as alphabets in an identifier. Hence _v
and v_
. Also that trailing underscores are recommended to avoid ambiguity with reserved keywords (class_
, case_
).
val abc_=0
<console>:1: error: '=' expected but integer literal found.
val abc_=0
Underscores being an important part of Scala typing system, what is the recommended way to use them in identifiers, so that parser and human can both be happy? What are all possible ambiguities that identifiers with underscores bring?
Leading whitespaces seem to add to confusion _class
instead of class_
.
Related questions: