get

abstract operator fun <T : Any> get(key: String): T?

Returns the value associated with the given key or null if no value is associated with the given key. The method return null if the type of the value is not the same as the type of the variable.

val context: Context = Context(1.toId(), host)
val value: Int? = context["key"]
val value: Int? = context["key"] ?: 0 // default value if null
val ping: Double = context["ping"]