Why this fails to compile:
scala> val a? = true
<console>:1: error: illegal start of simple pattern
val a? = true
^
and this works?
scala> val a_? = true
a_?: Boolean = true
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to the Scala language specification (looking at 2.8, doubt things have changed much since):
That is, an identifier can start with a letter or a digit followed by an underscore character, and further operator characters. That makes identifiers such as
foo_!@!valid identifiers. Also, note that identifiers may also contain a string of operator characters alone. Consider the following REPL session:Hope this answers your question.