美文网首页
Dart中的Cascade符号——".."

Dart中的Cascade符号——".."

作者: 小强开学前 | 来源:发表于2021-02-19 11:17 被阅读0次

    参考 tinyvampirepudge


    需要返回对象,但同时需要调用对象的一些方法。

    默认情况我们需要创建临时变量

    var temp = new Student();
    temp.setName("1");
    return temp;
    

    简略写法

    return new Student()..setName("1");
    

    类似 kotlin中的apply

    相关文章

      网友评论

          本文标题:Dart中的Cascade符号——".."

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