Why is 'do' necessary in a shutdown hook?

I found this bit of code on StackOverflow but I don’t fully understand it. In particular, I don’t understand the use of (do). Why is it needed? What if I simply had the println? Is do there in case I want to do multiple things?

(.addShutdownHook (Runtime/getRuntime)
                  (Thread.
                   #(do (println "ShutdownHook: app is shutting down"))))
1 Like

The do is not needed there, you can just use #(println ...). Perhaps originally the author of that code had some other forms in the body of the lambda.

1 Like