3 ms·
Make fields public final and your constructor is your "builder".
by emidln 9y ago
Make fields public final and your constructor is your "builder".
- positr0n 9y agoThose two patterns aren't the same. You can pass around a half constructed builder but you can't pass around a half constructed public final object like you described.
- dtech 9y agoYou can in most modern or functional languages, by currying/partial evaluation/binding. It's rare for data classes. In scala: case class Foo(a: Int, b: String) val halfBuilt: String => Foo = Foo(1, _) val foo = halfBuilt("foo")