Sign in using Google or Yahoo! id.  

Type casting in Scala

 Comments Share:   Twitter   Reddit   HackerNews   Facebook 

Example code to typecast as DataSource:

import javax.naming.InitialContext
import javax.sql.DataSource

val pool = "java:/comp/env/jdbc/MyPool"
val ic = new InitialContext()
val ds:DataSource = ic.lookup(pool).asInstanceOf[DataSource]

As you see, the asInstanceOf[...] does the magic of casting.

Posted on February 27, 2010 10:02 AM by Subhash Chandran
scala
blog comments powered by Disqus