 extension String {
     
     func allRangesOfCharacters(char: Character, inRange: NSRange) -> [NSRange] {
-        let string: NSString = self
         let charAsString = String(char)
         
-        var result = [NSRange]()
+        var result: [NSRange] = []
         
-        string.enumerateSubstringsInRange(inRange, options: .ByComposedCharacterSequences) { substr, range, _, _ in
-            if substr == charAsString {
-                result.append(range)
-            }
+        (self as NSString).enumerateSubstringsInRange(inRange, options: .ByComposedCharacterSequences) { substr, range, _, _ in
+            
+            guard substr == charAsString else { return }
+            
+            result.append(range)
         }
         
         return result

    
    func allRangesOfBeginingsOfTheLinesInRange(range: NSRange) -> [NSRange] {
        
        var result = [NSRange]()
        
        (self as NSString).enumerateSubstringsInRange(range, options: .ByLines) { substr, range, _, _ in
            var firstCharRange = range

    
    func allRangesOfCharacterInBeginigOfWord(char: Character, inRange range: NSRange) -> [NSRange] {
        
        guard letters.characterIsMember(char) else { return allRangesOfCharacters(char, inRange: range) }
        
        var result: [NSRange] = []
        var previousChar: Character?
        
        (self as NSString).enumerateSubstringsInRange(range, options: .ByComposedCharacterSequences) { substr, range, _, _ in
            let foundChar = substr?.characters.first!

            defer { previousChar = foundChar }
            
            guard foundChar == char else { return }
            guard previousChar != nil else { return result.append(range) }
            guard punctuation.characterIsMember(previousChar!) else { return }
            
            result.append(range)
        }
        
        return result
