Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala: keyword as package name

Tags:

scala

I'm trying to use a Java library (no source code available) which defines some xxx.xxx.object package. Scala complains about the presence of "object" in the package name, so I can't import from it, and I can't refer to its classes with fully qualified name either.

Is there a way around it?

like image 569
Germán Avatar asked Aug 01 '09 03:08

Germán


People also ask

What is package keyword in Scala?

Package in Scala is a mechanism to encapsulate a group of classes, sub packages, traits and package objects. It basically provides namespace to put our code in a different files and directories. Packages is a easy way to maintain our code which prevents naming conflicts of members of different packages.

What is a package object Scala?

Scala 2 provides package objects as a convenient container shared across an entire package. Package objects can contain arbitrary definitions, not just variable and method definitions. For instance, they are frequently used to hold package-wide type aliases and implicit conversions.


1 Answers

Wrapping the object in a ` (the quote next to 1) should work.

xxx.xxx.`object` 
like image 126
agilefall Avatar answered Oct 21 '22 07:10

agilefall