<@UCQSRLA2J> Similar to builders in Java, have it ...
# announcements
k
@Sam Similar to builders in Java, have it be a parameter of the
processor
function.
s
Thx, i'm assuming you meant like this?
Copy code
data class Processor ( val name : String )
fun processor( name : String, block : Processor.() -> Unit ) : Processor = Processor( name ).apply{ block() }

fun main( argv : Array<String> ) {
    processor ("Qualcomm" ) {
        // mutable properties
    }
}
k
Yep, you can even use named parameters at the callsite if that's clearer here.
s
Sure, so DSL kind of readable syntax works only with mutable properties 😞
k
You could write custom setters etc that throw exceptions when they're called twice, but nothing compile-time I'm afraid.
s
Got it