Created
September 15, 2014 19:59
-
-
Save arkadius/95795558f4cf287c41e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait CastingBox[T] { | |
val value: Any | |
def casted(implicit typeable: Typeable[T]): T = typeable.cast(value) match { | |
case Some(t) => t | |
case None => throw new ClassCastException(s"Cannot cast $value to expected type") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment