get

open operator fun <Root, Type> KProperty1<Root, Collection<Type>>.get(index: Int): Field<Root, Type>(source)

Refers to a specific item in an array, by its index.

Examples

class User(
val name: String,
val friends: List<Friend>,
)

class Friend(
val name: String,
)

// Refer to the first friend
println(User::friends[0])
// → 'friends.$0'

// Refer to the third friend's name
println(User::friends[2] / Friend::name)
// → 'friends.$2.name'

open operator fun <Root, Type> KProperty1<Root, Map<String, Type>>.get(index: String): Field<Root, Type>(source)

Refers to a specific item in a map, by its name.

Examples

class User(
val name: String,
val friends: Map<String, Friend>,
)

class Friend(
val name: String,
)

// Refer to the friend Bob
println(User::friends["bob"])
// → 'friends.bob'

// Refer to Bob's name
println(User::friends["bob"] / Friend::name)
// → 'friends.bob.name'