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
| /* | |
| This is a Swift Singleton. Lack of inline class variables right now make this a slightly more difficult task. | |
| Please ignore the oddly named class for the example. viewWillAppear made for good testing ;) | |
| */ | |
| class DetailViewController: UIViewController { | |
| func sharedInstance() -> DetailViewController { | |
| struct Container { | |
| static var instance: DetailViewController? | |
| static var token: dispatch_once_t = 0 |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>IDECodeSnippetCompletionPrefix</key> | |
| <string>swift_dispatch_once</string> | |
| <key>IDECodeSnippetCompletionScopes</key> | |
| <array> | |
| <string>All</string> | |
| </array> |
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
| /* | |
| In Swift, you can overload operators. A common operator in Ruby for working with arrays is <<, | |
| which is syntatic sugar for array.push(). Since Array's in Swift don't take bitwise operations, this is | |
| an example demonstrating adding that operator to an array that contains any type. | |
| As an extra tidbit, I've added >> to prepend an array with an object | |
| */ | |
| @infix func << <T>(inout array: Array<T>, item: T) { | |
| array.append(item) |
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
| require 'benchmark' | |
| class HashedFlags | |
| def initialize(opts = {}) | |
| @silly_prepend = opts.fetch(:silly_prepend, false) | |
| @uppercase = opts.fetch(:uppercase, false) | |
| end | |
| end | |
| SILLY_PREPEND = 0b00000001 |
NewerOlder