Created
May 26, 2016 04:03
-
-
Save austinzheng/25002ac5f1633fa5990354de3bcb77a5 to your computer and use it in GitHub Desktop.
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
func getString(collection: Any<Collection where .Element == String>, index: Int) -> String { | |
do collection openas T { | |
// T is available as a type. | |
// (Is this true?) T's associated types are also available, since T is opened into an explicit type. | |
var collectionIndex : T.Index = input.startIndex | |
for _ = 0..<index { | |
collectionIndex = collectionIndex.next(collection) | |
} | |
let returnValue : T.Element /* e.g. String */ = collection[collectionIndex] | |
return returnValue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment