Created
June 15, 2015 13:05
-
-
Save oisdk/047f86ca4ad068928f63 to your computer and use it in GitHub Desktop.
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
extension CollectionType { | |
subscript (inds: [Index]) -> [Generator.Element] { return inds.map{self[$0]} } | |
subscript (inds: Index...) -> [Generator.Element] { return inds.map{self[$0]} } | |
} | |
extension MutableCollectionType { | |
subscript (inds: [Index]) -> [Generator.Element] { | |
get { return inds.map{self[$0]} } | |
set(els) { for (ind, val) in zip(inds, els) { self[ind] = val } } | |
} | |
subscript (inds: Index...) -> [Generator.Element] { | |
get { return inds.map{self[$0]} } | |
set(els) { for (ind, val) in zip(inds, els) { self[ind] = val } } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment