An open API service indexing awesome lists of open source software.

https://github.com/phxql/kotlin-default-map

A map which returns a default value for missing keys
https://github.com/phxql/kotlin-default-map

Last synced: 3 months ago
JSON representation

A map which returns a default value for missing keys

Awesome Lists containing this project

README

          

# kotlin-default-map

A map which returns a default value for missing keys.

## Usage

```kotlin
val map = mapOf(1 to "one", 2 to "two").defaultsTo("???")

assertThat(map[1], equalTo("one"))
assertThat(map[2], equalTo("two"))
assertThat(map[3], equalTo("???"))

// Notice that value is of type String, not String?
val value: String = map[1]
```

## Downloading
### Gradle

```groovy
repositories {
maven {
url "https://dl.bintray.com/phxql/maven"
}
}

dependencies {
compile 'de.mkammerer:kotlin-default-map:1.0'
}
```

### Maven

Add this repository:

```xml



false

bintray-phxql-maven
bintray
https://dl.bintray.com/phxql/maven

```
You can then use the following Maven coordinates:

```xml

de.mkammerer
kotlin-default-map
1.0

```

## License

[LGPLv3](LICENSE)

## Maintainer

Moritz Kammerer ([@phxql](https://github.com/phxql))