Prevent Scala from parsing XML

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

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

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

Thank!

+4
source share
1 answer

No no.

Unfortunately, you will have to avoid this every time with backsticks.

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

Testing:

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

scala> `<?`(3)
3
+2
source

All Articles