https://kotlinlang.org logo
#getting-started
Title
# getting-started
r

reactormonk

07/11/2022, 4:16 PM
Does the concept of "an array of exactly 4 elements" exist in the kotlin type system? As an argument to my function.
l

Landry Norris

07/11/2022, 4:18 PM
Size is not a part of the type system in Kotlin. You can pass in an Array, but can’t specify the size. I would make a class called Array4 or something with a constructor that takes in 4 elements.
r

reactormonk

07/11/2022, 4:26 PM
Went for a
require
instead, not as nice, but should do
k

Klitos Kyriacou

07/11/2022, 4:30 PM
If your array required 2 or 3 elements, you could have used
Pair
or
Triple
. But there's no
Quadruple
.