The opinionated Tao of Optional Mappage


The opinionated Tao of Optional Mappage – Given these two functions: p(x) -> Void executes side effects in its body. f(x) -> y produces a transformed value Prefer: if let x = x { p(x) } to x.map({ p(x) }) when executing a function for its side effects. return x.map({ f(x) }) when returning a transformed value based on an optional. You may think of map as inherently functional but x.map({ p(x) }) does not warn on unused result. In this case, the return type is Void. If  … http://ow.ly/HgCR50aYCo5

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s