Jan
02/06/2022, 5:54 PMclass SelectionMenuOptionBuilder(val options: MutableList<SelectOption> = mutableListOf()) {
fun option(label: String = "", value: String = "", description: String? = null, emoji: Emoji? = null, default: Boolean = false) { options += SelectOption(label, value, description, emoji, default)}
fun add(selectOption: SelectOption) { options += selectOption }
fun addAll(selectOptions: Iterable<SelectOption>) { options += selectOptions }
fun addAll(selectOptions: Array<SelectOption>) { options += selectOptions }
}
Klitos Kyriacou
02/06/2022, 6:32 PMbuild()
function that returns an immutable List
.Nick Allen
02/06/2022, 6:43 PMbuildList
Mike Sutjipto
02/06/2022, 7:39 PMvalue class UserId(val value: String)
is a common way of using them (at least for me)Mykola Gurov
02/06/2022, 7:48 PMSelectOption
could’ve been a good candidate for the data class. The builder we see here is just a convenience wrapper around the mutable list, and TBH I’m not sure I even see any added value here since the clients of this class could’ve just used the same mutableList
directlyJan
02/06/2022, 10:28 PM