added component1() / component2() methods to Map.Entry along with a test case so that maps can be iterated over via: for ((k, v) in map)

This commit is contained in:
James Strachan
2012-09-14 11:18:35 +01:00
parent 7ad0fd56f3
commit 81d83cd4f0
2 changed files with 27 additions and 0 deletions
+10
View File
@@ -29,6 +29,16 @@ val <K,V> Map.Entry<K,V>.key : K
val <K,V> Map.Entry<K,V>.value : V
get() = getValue().sure()
/** Returns the key of the entry */
fun <K,V> Map.Entry<K,V>.component1() : K {
return getKey().sure()
}
/** Returns the value of the entry */
fun <K,V> Map.Entry<K,V>.component2() : V {
return getValue().sure()
}
/**
* Returns the value for the given key or returns the result of the defaultValue function if there was no entry for the given key
*