Skip to content

Instantly share code, notes, and snippets.

@Nub
Created June 23, 2014 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nub/638ca3ef0040136e5848 to your computer and use it in GitHub Desktop.
Save Nub/638ca3ef0040136e5848 to your computer and use it in GitHub Desktop.
% xcrun swift 1 ↵
Welcome to Swift! Type :help for assistance.
1> class Foo {
2. var num = 1
3. var string = "String"
4. }
5>
6> reflect(Foo())[0]
$R1: (String, Mirror) = {
0 = "num"
1 = {
_value = 1
summaryFunction =
quickLookFunction =
}
}
7> var numKey = reflect(Foo())[0].0
numKey: String = "num"
8> var numContainer = reflect(Foo())[0].1
numContainer: _LeafMirror<Int> = {
_value = 1
summaryFunction =
quickLookFunction =
}
9>
10> var stringKey = reflect(Foo())[1].0
stringKey: String = "string"
11> var stringContainer = reflect(Foo())[1].1
stringContainer: _LeafMirror<String> = {
_value = "String"
summaryFunction =
quickLookFunction =
}
12>
class Foo {
var num = 1
var string = "String"
}
reflect(Foo())[0]
var numKey = reflect(Foo())[0].0
var numContainer = reflect(Foo())[0].1
var stringKey = reflect(Foo())[1].0
var stringContainer = reflect(Foo())[1].1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment