Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created May 24, 2011 08:35
Show Gist options
  • Save xuwei-k/988340 to your computer and use it in GitHub Desktop.
Save xuwei-k/988340 to your computer and use it in GitHub Desktop.
DRYとか型安全を求めすぎて厨二病的なことになってる感じ
sealed trait ReturnType{
type A
val func:(String => A)
}
object ReturnType{
object IntType extends ReturnType{ type A = Int ; val func = (_:String).toInt }
object LongType extends ReturnType{ type A = Long ; val func = (_:String).toLong }
object StringType extends ReturnType{ type A = String ; val func = identity[String] _ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment