<Is there an elegant way to assign nullable types ...
# stackoverflow
u
Is there an elegant way to assign nullable types to optional parameters? Given I have the following function: fun leftPad(value: String, length: Int = 3, char: Char = ' '): String = value.padStart(length, char) Is there a way to be able to invoke this and pass values with nullable types to the optional parameters as in length: Int? = getLength() char: Char? = getChar() leftPad(value, length = length, char = char) The only workaround I've tried is the following fun leftPad(value: String, length: Int? = null, char: Char? = null): String { val length =...