Swift snippet #7 β€” Optional?

Ritesh Gupta
Swift Snippets πŸš€
1 min readDec 7, 2016

Wednesday, 7th December, 2016

The above snippet creates a not property on an optional variable which in case of a bool return its opposite value and otherwise it returns a false. You can relate this with my last snippet β€” swift-snippet#6.

I’ll share a code sample to show it usage..

It saves us from unnecessary if-lets or guard-lets to perform a simple reversal of a boolean value πŸš€

If you are wondering about the inception of Swift-Snippets or want to checkout more such snippets then you can find them here 😊

--

--