美文网首页
Kotlin记录

Kotlin记录

作者: 小强开学前 | 来源:发表于2019-12-02 09:47 被阅读0次

    1. kotlin类的调用顺序 调用顺序

    答:变量初始化 --> init{} --> constractor{}

    2. 内置内联函数的使用

    内部参数区别: this.length 可以直接写 length, it 不行。
    记得 it this返回值 就OK了。

    名称 有无返回值 内部参数 演示
    let 最后一行 it image
    run 最后一行 this 无差别 "123".run{ print(this)}
    with 最后一行 this 对象作为参数 with("123"){ print(this) }
    apply 对象本身 this image
    also 对象本身 it image

    相关文章

      网友评论

          本文标题:Kotlin记录

          本文链接:https://www.haomeiwen.com/subject/modxgctx.html