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
| @IBAction func submitTapped(sender: AnyObject) { | |
| validator.validateFieldByKey(Fields[0], delegate:self) | |
| validator.validateFieldByKey(Fields[1], delegate:self) | |
| } |
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
| // foo is automatically set to the `String` type | |
| let foo = "Hello" |
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
| // Throws errors | |
| let immutableString = "Clay is" | |
| immutableString += " awesome" | |
| // Works | |
| var mutableString = "Clay is" | |
| mutableString += " a big nerd" |
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
| // As an example, let's look at a reduction that creates a total sum | |
| // of an array of Floats with a different approaches, all with the same outcome: | |
| let total: [Float] -> Float = { $0.reduce(0, combine: +) } | |
| let total = transactions.reduce(0, {$0 + $1}) | |
| // It's easy to swap out operators to make it a multiplication, division, | |
| // or some other custom block execution. | |
| // Here we want to know if an entire list of booleans is true: |
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
| protocol PrintStrategy | |
| { | |
| func printString(string: String) -> String | |
| } |
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
| class CurrencyFactory | |
| { | |
| class func currencyForCountry(country:Country) -> Currency? | |
| { | |
| switch country | |
| { | |
| case .Spain, .France : | |
| return Euro() | |
| case .UnitedStates : |
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
| class SingletonClass | |
| { | |
| class var shared : SingletonClass | |
| { | |
| struct Static | |
| { | |
| static let instance : SingletonClass = SingletonClass() | |
| } | |
| return Static.instance |
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
| class DepositsController < BaseController | |
| include Manageable | |
| end |
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
| package main | |
| import ( | |
| "crypto/aes" | |
| "crypto/cipher" | |
| "encoding/base64" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" |
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
| import SpriteKit | |
| class GameScene: SKScene, SKPhysicsContactDelegate | |
| { | |
| // Our main scene. Everything is added to this for the playable game | |
| var moving: SKNode! | |
| // Our running man! Defaults to a stand still position | |
| let heroAtlas = SKTextureAtlas(named: "hero.atlas") | |
| var hero: SKSpriteNode! |