[Dart] learning - related Methods of Iterable

I. Overview

  • Set of values ​​or elements accessed sequentially, List also inherited a collection Iterable
  • Set List and also Iterable, dart: There are a lot of the same library collection
  • Iterable set may be modified portion
    • Add to List Set elements or objects will change all the elements it contains.
    • Map of Key to add a new element will change all of Map.keys.
    • After the set change, to create a new iterator will provide all the elements and may maintain the current order of the elements, may not

Second, create a way

  • Create an empty iterable
    var ite = Iterable.empty();
    print(ite); // ()
  • Create a Iterable, to dynamically generate a sequence of elements by
    var ite1 = Iterable.generate(5);
    print(ite1); // (0, 1, 2, 3, 4)

  As for the introduction and use Iterable all the attributes and functions, refer to List usage, since List is inherited from Iterable, so Iterable some properties and methods in both List

Guess you like

Origin www.cnblogs.com/lxlx1798/p/11371281.html