refactored the to(Collection) methods to be called toCollection(Collection) to avoid clashing with a potentially new method called to(T) for making a pair/tuple/Map.Entry

This commit is contained in:
James Strachan
2012-04-16 19:59:12 +01:00
parent 89eb7ba4ac
commit 87e613a8c2
13 changed files with 62 additions and 53 deletions
@@ -11,7 +11,7 @@ import java.util.*
//
/**
* Returns a new List containing the results of applying the given function to each element in this collection
* Returns a new List containing the results of applying the given *transform* function to each element in this collection
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
@@ -19,7 +19,10 @@ public inline fun <T, R> java.lang.Iterable<T>.map(transform : (T) -> R) : java.
return mapTo(java.util.ArrayList<R>(), transform)
}
/** Transforms each element of this collection with the given function then adds the results to the given collection */
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> java.lang.Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))