https://kotlinlang.org logo
Title
s

Shane Blackburn

11/01/2019, 5:06 PM
Does anyone have a good resource for learning collections in Kotlin? That is the one place I seem to really be struggling
w

wasyl

11/01/2019, 5:38 PM
Did you go through the collections section of Kotlin Koans? https://play.kotlinlang.org/koans/Collections/Introduction/Task.kt
j

jimn

11/02/2019, 3:25 PM
fun Shop.getSetOfCustomers(): Set<Customer> = TODO()
is just plain bad kotlin.
h

Hullaballoonatic

11/02/2019, 7:41 PM
do you mean because it's better to write as:
val Shop.customers get() = setOf(...)
?
If so, keep in mind this is tutorial. They're trying to help people learn the language fundamentals, and the official kotlin style of doing it would add an extra layer of confusion
styling code is bottom of priority when learning a language
☝️ 1
also the name implies the answer is
setOf(customers)
, which is incorrect. A python user might assume that is the way, and they need to learn how casting is done in Kotlin