https://kotlinlang.org logo
#advent-of-code
Title
# advent-of-code
j

Jonathan Kolberg

12/01/2023, 3:27 PM
Is there a way to declare in a base class that a function either takes a
List<String>
or a
Sequence<String>
and than in an override decide if you get the
List
or the
Sequence
? Or is this just overengineered and I should always take a
Sequence
?
p

Pavel Haluza

12/01/2023, 3:37 PM
I have this in my base class
Copy code
val input: Sequence<String> = // ...
val cachedInput: List<String> by lazy {
    input.toList()
}
Subclasses can use either. Both over- and under-engineered 😄
👀 2
j

Jonathan Kolberg

12/01/2023, 7:47 PM
Hm how do you then choose between test and real input?
12 Views