transformValues

Change the number of values that this option takes.

This overload changes the option to take a variable number of values, with the number of values falling within the nvalues range. If this option is called via an envvar, the list will contain one item, even if nvalues = 0..0.


Change the number of values that this option takes.

The input will be a list of size nvalues, with each item in the list being the output of a call to convert. If this option is called via an envvar, the list will contain one item, even if nvalues = 0.

nvalues cannot be 1, since option has nvalues = 1 by default. If you want to change the type of an option with one value, use convert instead.

This is used to implement functions like pair and triple. It must be applied after value conversions and before transformAll.

Example

data class Square(val top: Int, val right: Int, val bottom: Int, val left: Int)
val square by option().int().transformValues(4) { Square(it[0], it[1], it[2], it[3]) }