Support componentN for arrays and lists #KT-5538 Fixed

This commit is contained in:
Ilya Ryzhenkov
2014-11-05 18:42:08 +03:00
parent c2fabf5736
commit 2e154b73de
3 changed files with 424 additions and 0 deletions
@@ -434,5 +434,41 @@ fun elements(): List<GenericFunction> {
}
}
templates add f("component1()") {
inline(true)
doc { "Returns 1st *element* from the collection." }
returns("T")
body { "return get(0)" }
only(Lists, ArraysOfObjects, ArraysOfPrimitives)
}
templates add f("component2()") {
inline(true)
doc { "Returns 2nd *element* from the collection." }
returns("T")
body { "return get(1)" }
only(Lists, ArraysOfObjects, ArraysOfPrimitives)
}
templates add f("component3()") {
inline(true)
doc { "Returns 3rd *element* from the collection." }
returns("T")
body { "return get(2)" }
only(Lists, ArraysOfObjects, ArraysOfPrimitives)
}
templates add f("component4()") {
inline(true)
doc { "Returns 4th *element* from the collection." }
returns("T")
body { "return get(3)" }
only(Lists, ArraysOfObjects, ArraysOfPrimitives)
}
templates add f("component5()") {
inline(true)
doc { "Returns 5th *element* from the collection." }
returns("T")
body { "return get(4)" }
only(Lists, ArraysOfObjects, ArraysOfPrimitives)
}
return templates
}