Skip to content

Add DefaultWithMap #175

@LarsArtmann

Description

@LarsArtmann
    class DefaultWithMap<M, O>(private val entries: MutableMap<M, O> = mutableMapOf(), private val default: O) {

        operator fun getValue(input: M, property: KProperty<*>): O = entries[input] ?: default

        operator fun setValue(input: M, property: KProperty<*>, value: O) {
            if (value == null) entries.remove(input) else entries[input] = value
        }

    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions