rhartert
rhartert

Reputation: 53

Prevent Scala from parsing XML

I would like to define a function with this symbolic name without using backticks :

def <? (i: Int): Unit = println(i)

Unfortunately, this results in the following error identifier expected but $XMLSTART$< found. Is there a way to prevent Scala from parsing this symbolic name as XML ?

Thanks !

Upvotes: 4

Views: 373

Answers (1)

alcarv
alcarv

Reputation: 899

No, there's not.

Unfortunately you'll have to escape it every time with backsticks.

def `<?` (i: Int): Unit = println(i)

Testing it:

scala> def `<?` (i: Int): Unit = println(i)
$less$qmark: (i: Int)Unit

scala> `<?`(3)
3

Upvotes: 2

Related Questions