https://kotlinlang.org logo
#atrium
Title
# atrium
r

robstoll

01/12/2019, 6:45 PM
I would like to get some feedback concerning variable length argument lists. I am using the following pattern throughout the API for variable length argument lists:
first: T, vararg others: T
. For instance:
Copy code
fun <E : Any, T : Iterable<E>> Assert<T>.contains(expected: E, vararg otherExpected: E)
The intention behind it: this way one has to pass at least one argument (compiler is not happy otherwise). I would like to know what you experienced so far: 1️⃣ it was helpful 2️⃣ it is confusing/makes things more complicated
1️⃣ 2
c

charleskorn

01/13/2019, 2:26 AM
I prefer this because it means I can’t accidentally give no parameters at all, which is almost certainly a mistake
5 Views