Collections and iterators streamed, and tee

The complete source of flowControl_collections_pipeline.ek9, compiled by the EK9 compiler. Shown on flowControl.html.

#!ek9
defines module site.flowControl.collectionspipeline

  defines program  
    collectionsPipeLine()
      stdout <- Stdout()

      items <- ["Alpha", "Beta", "Charlie"]
      cat items > stdout

      //The alternative is when you already have an iterator
      moreItems <- ['A', 'B', 'C']
      iter <- moreItems.iterator()
      cat iter > stdout

      //An example of 'teeing' content out of a processing stream
      capturedValues <- List() of String
      cat ["Alpha", "Beta", "Charlie"], ["Delta", "Echo"] | tee in capturedValues > stdout
      require capturedValues?

Download flowControl_collections_pipeline.ek9

Output

Alpha
Beta
Charlie
A
B
C
Alpha
Beta
Charlie
Delta
Echo