Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a Java method named the same as a Scala keyword? [duplicate]

Tags:

java

scala

Possible Duplicate:
Using Java Lib with Scala Reserved Words

I'm experimenting with Scala, and a Java library I'm using has a with method on one of its objects, but with is a keyword in Scala. How do I call this method from my Scala code?

like image 221
Christopher Currie Avatar asked Jul 06 '11 21:07

Christopher Currie


Video Answer


1 Answers

From http://ofps.oreilly.com/titles/9780596155957/TypeLessDoMore.html#ReservedWords

Some Java methods use names that are reserved by Scala, e.g., java.util.Scanner.match. To avoid a compilation error, surround the name with single back quotes, e.g., java.util.Scanner.‵match‵.

(edited for formatting)

like image 97
Dylan Avatar answered Sep 27 '22 22:09

Dylan