一、Collections
kotlin 除了支持Java 中的基本数据类型之外,还有自己的集合变量 MutableList,MutableMap,MutableSet.
http://kotlinlang.org/docs/reference/collections.html
上面的传送门是kotlin 的官方解答,下边带着大家来看看
Unlike many languages, Kotlin distinguishes between mutable and immutable collections (lists, sets, maps, etc). Precise control over exactly when collections can be edited is useful for eliminating bugs, and for designing good APIs.
不像许多语言,kotlin是区分可变集合和不可变集合的(lists,sets,maps,等等)。更明确地控制可编辑的集合,有利于排除bug,同时设计更好的API。
It is important to understand up front the difference between a read-only view of a mutable collection, and an actually immutable collection. Both are easy to create, but the type system doesn't express the difference, so keeping track of that (if it's relevant) is up to you.
对于理解可变集合 和明确的不可变集合两者之间的不同是非常重要的。两个都是非常容易创建的,但是他们的系统数据类型没有明显差异,所以需要继续跟踪。
The Kotlin List type is an interface that provides read-only operations like size, get and so on. Like in Java, it inherits from Collection and that in turn inherits from Iterable. Methods that change the list are added by the MutableList interface. This pattern holds also for Set/MutableSet and Map/MutableMap.
和Java类似,Kotlin的List类型继承自Collection,进而继承自Iterable,List提供只读操作,如size,get等接口;而MutableList提供可变操作,即改变list的方法,这一模式也适用于:
Set/ MutableSet, Map/ MutableMap
官网给出的例子:
var list1:MutableList = mutableListOf("1","2")
list1.add(":")
val items = listOf(1, 2, 3)
...
二、回调处理 lambdas
http://kotlinlang.org/docs/reference/lambdas.html
关于这块儿呢 在android里边的使用基本高版本jdk 和编译器 都会给提示 多转几次就可以有心得,
值得注意的是有一种object:的对象参数 ,多写几次 就会有经验了
三、kotlin - Gson使用
对象之间的转换的话 没有什么可说的
只要是list的转化,特此记录