I think you're two choices are going to be a classic version and the on you used. The classic one would look like this.
let myCollectionView: UICollectionView = UICollectionView()
I'm assuming there aren't required parameters.
Generally speaking I don't use closures for things when I can make it more explicit otherwise. I find they read poorly and depending on the language and situation you have to know that the closure executes on a seperate thread or execution context.
I've not used the closure based way before, so I can't speak to its long term usefulness. My first reaction to it is that I'd probably not use it unless I was doing something very complex that wrapping it up a function wouldn't cover.
Thank you so much!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.