[swift-users] String Comparisons in Swift

Erica Sadun erica at ericasadun.com
Thu Jun 2 15:48:37 CDT 2016


> On Jun 2, 2016, at 1:07 PM, John Myers via swift-users <swift-users at swift.org> wrote:
> 
> I've had some difficulty comparing string variables to string constants with ==.  I believe it's always after using a readLine().  Does Swift require a .equals() or a .compareTo(), as other c like languages, or are there invisible characters in my string because of the readLine() which I need to strip out?
> Thanks!

Have you compared characters.count on the two strings? Could you be pulling in \r\n?

-- E




More information about the swift-users mailing list