Last active
August 29, 2015 14:09
-
-
Save kichiemon/e9de5170fc094899bca3 to your computer and use it in GitHub Desktop.
[Spider]Swiftと似た?を使ったチェーンのメモ ref: http://qiita.com/iKichiemon/items/f240a89665f8e4ec4ce3
This file contains 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
var name:String? |
This file contains 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 Animal { | |
func name()->Void{ | |
println("animal") | |
} | |
} | |
var animal:Animal? | |
animal = Animal() | |
animal?.name() |
This file contains 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
func Animal() { | |
this.name = () -> { | |
return "Dog" | |
} | |
} | |
var animal = new Animal() | |
animal.name() | |
var name = animal.name?() // "Dog" | |
var age = animal.age?() // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment