Skip to content

Instantly share code, notes, and snippets.

@matsu-chara
Created May 27, 2017 16:13
Show Gist options
  • Save matsu-chara/46e268cd525ec44dfab94bd0db43bcd4 to your computer and use it in GitHub Desktop.
Save matsu-chara/46e268cd525ec44dfab94bd0db43bcd4 to your computer and use it in GitHub Desktop.
基本的には実装詳細を隠蔽しつつDBに入れる時など限定で値を取り出す方法
case class Foo(value: Int)
case class Bar(value: String)
case class Baz(private val foo: Foo, private val bar: Bar) {
def fooBar: String = foo.value.toString + bar.value
}
val baz = Baz(Foo(1), Bar("bar"))
scala> Baz.unapply
case def unapply(x$0: Baz): Option[(Foo, Bar)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment