Scala Closure Example

Somewhat more real example

Closures aren’t new to me. I’ve used them a bunch when I’ve done JavaScript however I felt like the concept of a closure was really well defined/understood in JavaScript. Although I was aware you could likely (wasn’t sure until I google’d) do it Scala, every example online infuriated me!
Every example was pretty trivial (i.e. summing function) and used a global variable.
I wanted to give a better example!

Example

Leave a Reply

Your email address will not be published. Required fields are marked *