Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension CollectionType where Self.Generator.Element == String {
- func find(subString:String) -> Int {
- for (i,s) in self.enumerate() {
- if s.containsString(subString) {
- return i
- }
- }
- return -1
- }
- }
- extension CollectionType where Self.Generator.Element == Int {
- func find(i:Int) -> Int {
- for n in self {
- if n == i {
- return n
- }
- }
- return -1
- }
- }
- let a = ["1222", "abdc", " anc abc", "abc abc", "123"]
- let b = [1, 2, 3, 5, 5, 6, 9, 10]
- a.find("abc")
- b.find(11)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement