Adding Money with a pipeline

The complete source of builtInTypes_money_pipeline.ek9, compiled by the EK9 compiler. Shown on builtInTypes.html.

#!ek9
defines module site.builtintypes.moneypipeline

  defines program

    MoneyPipeline()
      stdout <- Stdout()

      tenPounds <- 10.00#GBP
      ninetyNinePoundsFiftyOnePence <- 99.51#GBP
      fortyNinePoundsSeventySixPence <- 49.76#GBP

      total <- cat [tenPounds, ninetyNinePoundsFiftyOnePence, fortyNinePoundsSeventySixPence] | collect as Money

      stdout.println(total)

Download builtInTypes_money_pipeline.ek9

Output

159.27#GBP