//map源码
fun <T, R> List<T>.map1(transform: (T) -> R): List<R> {
val result = arrayListOf<R>()
for (item in this)
result.add(transform(item))
return result
}
//演示list
var ints = asList(1, 10, 20, 30)
val doubledList = ints.map { it -> it * 2 }
println("double list:"+doubledList);
// index =0 item[0]=1 1*2=2 2. 20 .40 60 double list:[2, 20, 40, 60]
//高级一点的
val fruits = listOf("banana", "avocado", "apple", "kiwi","bbaaaa")
fruits
.sortedBy {it }
.filter { it.startsWith("a") }//只需要a开头的
.map { it.toUpperCase() }//all upper//并转换为大写
.forEach { println("current ${it}") }//after print
//上面的高阶顺序基本上不可以调整否则语法报错