A way to prepend letters to each imported class

Is there a way to import all classes from a package and rename them all by prepending some text? A construct

import packages.{_ => Abc_}

compiles but seems not to be doing that thing.


No, no way to do such a thing.

"Programming in Scala, 2nd Edition" 13.3, which is 2.9 based, defines the rules. I don't recall anything in the changes for 2.10 that alters the import mechanism.

Given import package.{selector}, selector may be one of:

  • x, a simple name

  • x => y, renaming x to y

  • x -> _, hiding x - excludes from names imported

  • _, the catch-all - import all names.

That's it. Your variant looks interesting, but isn't in that list. It is interesting that {_ => ...} compiles for various values of ..., but it's not clear that the effect is any different than _ for the few trials I ran.

It's not exactly what you're after, but if you can put up with an extra . character, you could write

import com.{packages=>Abc}
val x:Abc.Whatever = new Abc.Whatever(...)

Need Your Help

How does one pass applicaton private files to android Service in a separate process

android security service

I am a bit of a noob at android but I have an application where one part of the application generates large data files which I want to schedule into a service running as a separate process (for

localScroll next prev button

anchor scrollto next

iam creating an fullscreen scroller, with localScroll/scrollTo.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.