Last active
October 10, 2022 21:07
-
-
Save chockenberry/5916dc25d4ff12d6a376a661558fc721 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
import Foundation | |
let okString = "WTF\r\nHELLO" | |
let wtfString = AttributedString(okString) | |
if let lineRange = okString.range(of: "\n") { | |
let lineSubstring = okString[okString.startIndex..<lineRange.lowerBound] | |
type(of: lineSubstring) | |
lineSubstring.count | |
} | |
if let lineRange = wtfString.range(of: "\n") { | |
let lineSubstring = wtfString[wtfString.startIndex..<lineRange.lowerBound] | |
type(of: lineSubstring.characters) | |
lineSubstring.characters.first! | |
lineSubstring.characters.last! | |
lineSubstring.characters.count // BOOM | |
// same with lineSubstring.characters.underestimatedCount | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment