Created
July 12, 2022 03:00
-
-
Save Catfish-Man/56ece650e4af67d88b3d02eabd8c6329 to your computer and use it in GitHub Desktop.
How many different kinds of NSString can we generate with the same code?
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 | |
func examine(_ str: String) { | |
print("\"\(str)\"") | |
print("bridges as: \(type(of: str as NSString))") | |
str.withCString { | |
print("inits an NSString as: \(type(of: NSString(cString: $0, encoding: String.Encoding.ascii.rawValue)!))") | |
} | |
print("\n") | |
} | |
examine("hellohello") | |
examine("hellohellQ") | |
examine("hQllo") | |
examine("hëllo") | |
examine("hellohellohellohello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment