intersperse 2.0.0 copy "intersperse: ^2.0.0" to clipboard
intersperse: ^2.0.0 copied to clipboard

Insert an element between each element of an Iterable or List.

intersperse #

extra_pedantic on pub.dev Travis CI Codecov Pub.dev License Github Stars Twitter Follow GitHub Follow

Insert an element between each element of an Iterable or List.


    final list1 = intersperse(2, <int>[]); // [];
    final list2 = intersperse(2, [0]); // [0];
    final list3 = intersperse(2, [0, 0]); // [0, 2, 0];
    final list1Outer = intersperseOuter(2, <int>[]); // [];
    final list2Outer = intersperseOuter(2, [0]); // [2, 0, 2];
    final list3Outer = intersperseOuter(2, [0, 0]); // [2, 0, 2, 0, 2];

This can also be used as an extension method:

    final list1 = <int>[].intersperse(2); // [];
    final list2 = [0].intersperse(2); // [0];
    final list3 = [0, 0].intersperse(2); // [0, 2, 0];
    final list1Outer = <int>[].intersperseOuter(2); // [];
    final list2Outer = [0].intersperseOuter(2); // [2, 0, 2];
    final list3Outer = [0, 0].intersperseOuter(2); // [2, 0, 2, 0, 2];
48
likes
160
points
73.1k
downloads

Publisher

verified publishermodulovalue.com

Weekly Downloads

Insert an element between each element of an Iterable or List.

Repository

Documentation

API reference

License

MIT (license)

More

Packages that depend on intersperse