https://kotlinlang.org logo
Title
b

Ben Keil

04/18/2023, 3:27 PM
at the moment some methods are duplicates, e.g.
JobBuilder.run()
. it’s a little bit annoying to implement new fields twice. the only difference is that the one function has an optional name parameter and the other one not. if we would just remove the function without the param, it would collide with kotlin’s native
run
method. one solution would be to switch the order of the params. from
public fun run(
        name: String? = null,
        command: String,
to
public fun run(
        command: String,
        name: String? = null,
but it will break some implementations (you see it probably first when the pipeline runs) beside that, would it be a good idea to force people to use named parameter, like we do in actions? this would make extensions in the future also easier.
p

Piotr Krzemiński

04/18/2023, 6:50 PM
I'm fine with making the breaking change resulting from removing one overload and switching order of the first two args. Regarding enforcing named arguments, I need to think about it for a sec - probably makes sense, but would be happy to know opinion of some users
n

Nikky

04/18/2023, 7:54 PM
can we even do that ? i mean… people could still call it by order of arguments without specifying names.. it would just be unreadable and tedious…
p

Piotr Krzemiński

04/18/2023, 7:56 PM
people could still call it by order of arguments without specifying names..
What do you mean? There's a way to enforce using only named arguments
Someone may argue that not using named arguments is unreadable :)
E. g. in my company we write in Python and we have an internal code style where we must use named arguments