That's something that I would like to know for sure. As far as I understood it, foreach will iterate over the collection and call the side-effect for each element. After the collection has been exhausted, the side-effect2 will be called. I'll try to find more info on this and clarify the docs.