miha-x64
01/21/2017, 8:56 PMfun get(count: Int = 20): List<Item>
. I call impl.get()
and I want to know that I expect 20 items.orangy
miha-x64
01/21/2017, 9:00 PMorangy
benleggiero
01/21/2017, 11:49 PMbenleggiero
01/21/2017, 11:50 PMbenleggiero
01/21/2017, 11:51 PMinterface Foo {
companion object {
val defaultGetCount = 20
}
fun get(count: Int = defaultGetCount): List<Item>
}
adam-mcneilly
01/22/2017, 7:15 AMMap<String, List<Event>>
and I want to flatmap that into one straight list of objects, what is the easiest way to do so?adam-mcneilly
01/22/2017, 7:18 AMadam-mcneilly
01/22/2017, 7:21 AMsailxjx
01/22/2017, 7:23 AMgetter
method to define the type of variables:
val myString get() = "hi"
However, when I use var myString get() = “hi”
, I got an error message “Property must be initialized”, I think it should work on both val
and var
.sailxjx
01/22/2017, 7:26 AMvar str1 = “Hi”
val str2 get() = str1
When the str1 is changed, then str2 is changed, so this means val
can not keep the value of str2 immutable?cedric
01/22/2017, 8:02 AMflatMap {it -> it}
adam-mcneilly
01/22/2017, 8:02 AMcedric
01/22/2017, 8:02 AMmapOf("a" to listOf(1, 2), "b" to listOf(3, 4, 5)).values.flatMap { it -> it }
[1, 2, 3, 4, 5]
cedric
01/22/2017, 8:02 AMadam-mcneilly
01/22/2017, 8:03 AMadam-mcneilly
01/22/2017, 8:04 AMcedric
01/22/2017, 8:04 AMCollection<Any>
, not exactly easy to handleadam-mcneilly
01/22/2017, 8:04 AMList<Any>
cedric
01/22/2017, 8:04 AMadam-mcneilly
01/22/2017, 8:04 AMcedric
01/22/2017, 8:07 AMmap.entries
adam-mcneilly
01/22/2017, 8:10 AMcedric
01/22/2017, 8:11 AMadam-mcneilly
01/22/2017, 8:13 AMMap<String, List<Event>>
so I have each day and its events in their own bucket.
I know Friday is index 0, because it's the first key. Friday's first event would be index 1, and so on down the line. What I'm having trouble with is recreating this logic programatically. I don't want to have to walk my way from key -> values, key -> values each time to reach my position. Is that more clear?cedric
01/22/2017, 8:14 AMadam-mcneilly
01/22/2017, 8:15 AMcedric
01/22/2017, 8:16 AMclass Display(day: String, events: List<Event>>)
and a list of those?