has anyone found a way to force mandatory paramete...
# getting-started
e
has anyone found a way to force mandatory parameters in DSL other than moving them as constructor arguments?
j
A bunch of DSLs are functions rather than constructors, so I would say function arguments as well. I don't think you can have compile errors if you use a "property assignment" approach, if that's what you're looking for. You can generate runtime errors though, but I'd honestly prefer function or constructor arguments. What do you not like about those?
Another option is to provide a reasonable default of course, but I think that's not the scope of the question
e
maybe with Contracts?
damn
Contracts are allowed only for functions
d
It's very nice to see links to my masters degree Samples from this repo very may as example for this degree and weren't be accepted to master of kotlin in this way But I think we will revisit them in K2 compiler
e
@dmitriy.novozhilov is there an update on which solutions are available right now? Also with weird workarounds or additional code overhead
d
No, there is nothing on compiler side But you can create a workaround on your API side: you can pass required values to arguments of builder function, and initialize in lambda only optional ones