I'm currently following Julia for pythonistas notebook by Aurelien Geron (https://github.com/ageron/julia_notebooks) and I'm a bit confused on annonymous functions chapter with the following code:
handlers = []
on_click(handler) = push!(handlers, handler)
click(event) = foreach(handler->handler(event), handlers)
on_click() do event
println("Mouse clicked at $event")
end
on_click() do event
println("Beep.")
end
click((x=50, y=20))
click((x=120, y=10))
Run Code Online (Sandbox Code Playgroud)
Mainly I can't see how on_click() gets the event from click(). Can anyone shed some light on it?
julia ×1