Skip to content

Commit 5248e22

Browse files
committed
s/Conversions/Converters/ , s//asScala/ (watch that last one, it's a doozy)
1 parent ce43bff commit 5248e22

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

web/coll2.textile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,13 @@ res56: numbers.type = Map((2,3), (4,1), (1,2))
363363

364364
h2(#java). Life with Java
365365

366-
You can easily move between Java and Scala collection types using a set of implicit conversions that are available in the JavaConversions package.
366+
You can easily move between Java and Scala collection types using conversions that are available in the <a href="http://www.scala-lang.org/api/current/index.html#scala.collection.JavaConverters$">JavaConverters package</a>. It decorates commonly-used Java collections with <code>asScala</code> methods and Scala collections with <code>asJava</code> methods.
367367

368368
<pre>
369-
import scala.collection.JavaConversions._
369+
import scala.collection.JavaConverters._
370370
val sl = new scala.collection.mutable.ListBuffer[Int]
371-
val jl : java.util.List[Int] = sl
372-
val sl2 : scala.collection.mutable.Buffer[Int] = jl
371+
val jl : java.util.List[Int] = sl.asJava
372+
val sl2 : scala.collection.mutable.Buffer[Int] = jl.asScala
373373
assert(sl eq sl2)
374374
</pre>
375375

web/concurrency.textile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,18 +379,18 @@ If you look at the implementation, you realize that it's simply synchronizing on
379379

380380
h2. Java ConcurrentHashMap
381381

382-
Java comes with a nice thread-safe ConcurrentHashMap. Thankfully, we can use JavaConversions to give us nice Scala semantics.
382+
Java comes with a nice thread-safe ConcurrentHashMap. Thankfully, we can use JavaConverters to give us nice Scala semantics.
383383

384384
In fact, we can seamlessly layer our new, thread-safe InvertedIndex as an extension of the old unsafe one.
385385

386386
<pre>
387387
import java.util.concurrent.ConcurrentHashMap
388-
import scala.collection.JavaConversions._
388+
import scala.collection.JavaConverters._
389389

390390
class ConcurrentInvertedIndex(userMap: collection.mutable.ConcurrentMap[String, User])
391391
extends InvertedIndex(userMap) {
392392

393-
def this() = this(new ConcurrentHashMap[String, User])
393+
def this() = this(new ConcurrentHashMap[String, User] asScala)
394394
}
395395
</pre>
396396

0 commit comments

Comments
 (0)