July 28, 2008

Renaming imports

One useful thing if you're spending a lot of time interfacing with Java from Scala is renaming imports.

I use scala ArrayLists and java.util.ArrayList a lot. Here's an easy way to not get confused:
import java.util.{ArrayList => JArrayList}

1 comment:

jherber said...

nice.

this is could also be used to annotate what data structures are mutable in scala. for example, just as some of those naughty puritans wore a scarlet "S" for their sins, we can tag modern sinners with an "M" for mutable. e.g.:

import java.util.(ArrayList => M_ArrayList)

if this were a scala convention, we could write a code metric tool that searched the code base for mutable data structures not so aptly named, and probably help lower the mistakes made between "accidental" imperative and "intentional" fp programming in a fusion language.