Skip to content

Instantly share code, notes, and snippets.

View didats's full-sized avatar

Didats Triadi didats

View GitHub Profile
@didats
didats / find_position.swift
Created September 16, 2016 01:17
Finding index position of a string from a string with swift 3
// case sensitive
func findPosition(of: String, from: String) -> Int {
if let range : Range<String.Index> = from.range(of: of) {
return from.distance(from: from.startIndex, to: range.lowerBound)
}
return -1
}
findPosition(of: "adi", from: "Didats Triadi")