Convert Option[Object] to Option[Int] Implicitly
- by wheaties
I'm working with legacy Java code which returns java.lang.object. I'm passing it into a function and I'd like to do some implicit conversions as such:
implicit def asInt( _in:Option[Object] ) = _in asInstanceOf[ Option[Int] ]
implicit def asDouble( _in:Option[Object] = _in asInstanceOf[ Option[Double] ]
private def parseEntry( _name:String, _items:Map[String,Object] ) = _name match{
case docName.m_Constants =>
new Constants( _items get( Constants m_Epsilon ), _items get( Constant m_Rho ),
_items get( Constants m_N ) )
Technically it goes on but I keep getting the same errors: expected Int, Option[Object] found.
How have I done my implicits wrong? I was hoping it would do the transformation for me instead of me having to write "asInstanceOf" each and every time.