You can provide an anonymous function in any situation where you might have used a lambda expression. However, while you can have a trailing parameter's lambda expression be outside of the function call (e.g., events.first { == 1337 }), anonymous functions have to passed inside the function call, as would ordinary parameters.

You can learn more about this in:
Run Edit