https://kotlinlang.org logo
Title
d

diesieben07

05/07/2018, 9:14 AM
Either
list.associate { key to value }
or
list.associateBy { key }
👍 1
e

elect

05/07/2018, 9:16 AM
Any way I can shorten this by using something else at the
partition
step?
val properties = FiledOrder::class.declaredMemberProperties
    val parts = properties.partition { it.findAnnotation<FiledOrder.Order>() != null }
    val plain = parts.first.sortedBy { it.name }
    val annotated = parts.second.associateBy { it.findAnnotation<FiledOrder.Order>()!!.value }
I want to have a list of properties without the given annotation, and I want a map of the others, using the annotation
value
as key
class FiledOrder {
    @Retention(AnnotationRetention.RUNTIME)
    annotation class Order(val value: Int)
d

diesieben07

05/07/2018, 9:19 AM
I can't find anything shorter right now tbh. Looks okay
e

elect

05/07/2018, 9:38 AM
ok