Skip to content

Commit

Permalink
Swift version check to support < v4 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
conqueror authored Mar 17, 2018
1 parent 4484a2e commit c6e70a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/Lingo/StringInterpolator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ class StringInterpolator {
/// The function finds all placeholders and replaces them with a value specified in interpolations dictionary
func interpolate(_ rawString: String, with interpolations: [String: Any]) -> String {
var result = rawString

let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.count))

#if swift(>=4)
let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.count))
#else
let matches = StringInterpolator.regularExpression.matches(in: rawString, options: [], range: NSRange.init(location: 0, length: rawString.characters.count))
#endif
for match in matches {
let range: NSRange = match.range

Expand Down

0 comments on commit c6e70a4

Please sign in to comment.