Author: Chris Lattner
It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Idea for this comes from https://gist.github.com/austinzheng/8fda3f61e1fd06383928#file-main-swift-L19 | |
In an iOS 7.x supporting app which can't use UIAlertController, rather than fork execution paths based on iOS version, we could wire up an old fashioned UIAlertView this way. Still feels more 'block' based and clean to handle, since all the UIAlertViewDelegate stuff is contained within the 'nested-class-in-closure'. | |
*/ | |
class SampleViewController: UIViewController { | |
var askTheUserSomethingAlert: UIAlertView | |
var strongAlertDelegate: UIAlertViewDelegate? | |
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.