fold() is designed to perform some computation on all items in the list, returning the result of the last computation.

fold() takes a starting value as a parameter, along with a lambda expression. fold() then calls the lamba expression, passing in the starting value plus the first item from the list. The result of that lambda expression then gets passed back into the lambda expression, along with the second item from the list. This continues through to the last item in the list, and fold() returns whatever that last lambda expression evaluates to.

In this case, we create a string with a comma-delimited list of the events.

You can learn more about this in:
Run Edit