Repository: ktorio/ktor
File: ktor-utils/common/src/io/ktor/util/Attributes.kt (Kotlin)

Code before:
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.getOrNull)
     */
    public fun <T : Any> getOrNull(key: AttributeKey<T>): T?

    /**
     * Checks if an attribute with the specified [key] exists
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.contains)
     */
    public operator fun contains(key: AttributeKey<*>): Boolean

    /**
     * Creates or changes an attribute with the specified [key] using [value]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.put)
     */
    public fun <T : Any> put(key: AttributeKey<T>, value: T)

    /**
     * Creates or changes an attribute with the specified [key] using [value]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.set)
     */
    public operator fun <T: Any> set(key: AttributeKey<T>, value: T) {
        put(key, value)
    }

    /**
     * Removes an attribute with the specified [key]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.remove)
     */
    public fun <T : Any> remove(key: AttributeKey<T>)

    /**
     * Removes an attribute with the specified [key] and returns its current value, throws an exception if an attribute doesn't exist
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.take)
     */
    public fun <T : Any> take(key: AttributeKey<T>): T = get(key).also { remove(key) }

    /**
     * Removes an attribute with the specified [key] and returns its current value, returns `null` if an attribute doesn't exist
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.takeOrNull)
     */
    public fun <T : Any> takeOrNull(key: AttributeKey<T>): T? = getOrNull(key).also { remove(key) }

    /**
     * Gets a value of the attribute for the specified [key], or calls supplied [block] to compute its value
     *

Review comment (suggestion):
I'm not sure why we didn't use the set operator here before, maybe the type argument wasn't supported in earlier Kotlin versions.

Code after:
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.getOrNull)
     */
    public fun <T : Any> getOrNull(key: AttributeKey<T>): T?

    /**
     * Checks if an attribute with the specified [key] exists
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.contains)
     */
    public operator fun contains(key: AttributeKey<*>): Boolean

    /**
     * Creates or changes an attribute with the specified [key] using [value]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.put)
     */
    public fun <T : Any> put(key: AttributeKey<T>, value: T)

    /**
     * Creates or changes an attribute with the specified [key] using [value]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.set)
     */
    public operator fun <T : Any> set(key: AttributeKey<T>, value: T) {
        put(key, value)
    }

    /**
     * Removes an attribute with the specified [key]
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.remove)
     */
    public fun <T : Any> remove(key: AttributeKey<T>)

    /**
     * Removes an attribute with the specified [key] and returns its current value, throws an exception if an attribute doesn't exist
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.take)
     */
    public fun <T : Any> take(key: AttributeKey<T>): T = get(key).also { remove(key) }

    /**
     * Removes an attribute with the specified [key] and returns its current value, returns `null` if an attribute doesn't exist
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.Attributes.takeOrNull)
     */
    public fun <T : Any> takeOrNull(key: AttributeKey<T>): T? = getOrNull(key).also { remove(key) }

    /**
     * Gets a value of the attribute for the specified [key], or calls supplied [block] to compute its value
     *