How do method cascades work exactly in dart?

前端 未结 3 406
夕颜
夕颜 2020-12-15 05:43

As stated in the dart article:

The \"..\" syntax invokes a method (or setter or getter) but discards the result, and returns the original receiver ins

3条回答
  •  遥遥无期
    2020-12-15 06:08

    A..B().C() means calling B() on A, then calling C() based on the return value of A.B().

    A..B().C()..D().E() means calling B() on A, then calling C() based on the return value of A.B(), assume it is A_B, then calling D() on A_B, i.e. A_B.D(), assume the return value of it is A_B_D, then finally do A_B_D.E().

提交回复
热议问题