Skip to content

Instantly share code, notes, and snippets.

@awekuit
Last active August 29, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awekuit/79f76346191488a57aa9 to your computer and use it in GitHub Desktop.
Save awekuit/79f76346191488a57aa9 to your computer and use it in GitHub Desktop.
Scalaで、型シグネチャが同じcase class同士を変換する
case class Foo(a: Int, s: String)
case class Bar(a: Int, s: String)
val foo = Foo(100, "hey!")
// foo: Foo = Foo(100,hey!)
val bar = Bar.tupled(Foo.unapply(foo).get)
// bar: Bar = Bar(100,hey!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment