4 ms·
I've come to love Scala case classes: case class Foo(bar: String, foo: String = "hello") new Foo(bar = "Hey there") new Foo(foo = "Hey there", bar = "Hel
by Uchikoma 14y ago
I've come to love Scala case classes:
case class Foo(bar: String, foo: String = "hello")
new Foo(bar = "Hey there")
new Foo(foo = "Hey there", bar = "Hello")
new Foo("Hey there")
- hythloday 14y agoCase classes, I believe, have a companion object with an apply method build for them, so you can get it down to: case class Foo(bar: String, foo: String = "hello") val f1 = Foo(bar = "Hey there") val f2 = Foo(foo = "Hey there", bar = "Hello") val f3 = Foo("Hey there")
- Uchikoma 14y agoYou're right!