ilya.gorbunov
06/22/2016, 3:08 PMmapIndexed {i, v -> IndexedValue(i, v)}
is just .withIndex()
rocketraman
06/22/2016, 3:08 PM@Suppress("UNCHECKED_CAST")
fun <R> Iterable<*>.filterIsInstanceIndexed(clazz: Class<R>): List<IndexedValue<R>> =
withIndex().filter { clazz.isInstance(it.value) } as List<IndexedValue<R>>
kirillrakhman
06/22/2016, 3:15 PMclazz
parameter by making the function inline and making R
reifiedkirillrakhman
06/22/2016, 3:15 PM@Suppress("UNCHECKED_CAST")
inline fun <reified R: Any> Iterable<*>.filterIsInstanceIndexed(): List<IndexedValue<R>> =
withIndex().filter { it.value is R } as List<IndexedValue<R>>
kirillrakhman
06/22/2016, 3:17 PMrocketraman
06/22/2016, 3:20 PMfilterIsInstance
doesn't use reification?kirillrakhman
06/22/2016, 3:21 PMkirillrakhman
06/22/2016, 3:21 PMkirillrakhman
06/22/2016, 3:22 PMrocketraman
06/22/2016, 3:23 PMdean
06/24/2016, 4:30 AMdean
06/24/2016, 4:31 AMlateinit val
becoming a thingdean
06/24/2016, 4:31 AMkevinmost
06/24/2016, 5:12 AMlateinit val
become a thing? I don't think the compiler can know that you've set a property exactly one time outside of the init
block. That depends on things happening at runtime.hoang
06/24/2016, 5:59 AMvoddan
06/24/2016, 6:46 AMMap<K, List<V>>
or something similarhoang
06/24/2016, 6:52 AMvoddan
06/24/2016, 6:54 AMhoang
06/24/2016, 7:04 AMcedric
06/24/2016, 11:42 AMMultimap
hoang
06/24/2016, 12:08 PMjw
06/24/2016, 3:02 PMilya.gorbunov
06/24/2016, 3:09 PMjw
06/24/2016, 3:22 PMfun <K, V> MutableMap<K, MutableList<V>>.put(key: K, value: V) = getOrPut(key, { mutableListOf() }).add(value)
jw
06/24/2016, 3:24 PMpabl0rg
06/27/2016, 6:10 AMpabl0rg
06/27/2016, 6:12 AMdata class DataPoint(val date: ZonedDateTime, val value: Int): ToInt by value
kirillrakhman
06/27/2016, 7:20 AMreduce
is the way to govoddan
06/27/2016, 7:23 AMvoddan
06/27/2016, 7:24 AM