Skip to content

Instantly share code, notes, and snippets.

@kubukoz
Created July 15, 2017 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubukoz/397e049325dc9793ee79d6572a8c9494 to your computer and use it in GitHub Desktop.
Save kubukoz/397e049325dc9793ee79d6572a8c9494 to your computer and use it in GitHub Desktop.
object ChainedConversions {
implicit def chain[A, B, C](implicit ab: A => B, bc: B => C): A => C = ab andThen bc
implicit val intToString: Int => String = _.toString
class X
implicit val stringToX: String => X = _ => new X
val a: X = 5 // idea marks it as a proper conversion
//doesn't compile though
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment