Skip to content

Commit

Permalink
Merge pull request #84 from cubandle/putlast
Browse files Browse the repository at this point in the history
Optimize putLast
  • Loading branch information
KiARC committed Jan 15, 2023
2 parents 0f6c009 + 800e958 commit 3660f70
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ fun DateTimeUnit.toMillis(): Long {
* Puts the specified value to the last key in this map.
*/
fun <K, V> LinkedHashMap<K, V>.putLast(value: V) {
val lastKey = keys.map { it }.last()
put(lastKey, value)
put(keys.last(), value)
}

0 comments on commit 3660f70

Please sign in to comment.