Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code snippets for Swift symposium #2
// About character counting in UTF-8 and Swift
var str = "かきくがぎぐ🇯🇵"
str.characters.count
str.unicodeScalars.count
let s1 = "\u{E9}"
let s2 = "\u{65}\u{301}"
// Compatibility equivalence and Canonical Equivalent
(s1 == s2)
(s1 as NSString) == (s2 as NSString)
let a = (s1 as NSString).compare(s2)
a.rawValue
let taka1 = ""
let taka2 = "" // ハシゴの方
let isEq = (taka1 == taka2)
// overloadの評価基準がSwiftに明確に書かれていない
func hoge(hoge:String) -> Int {
return 1
}
func hoge(hoge:Int) -> Int {
return 2
}
func hoge(hoge:AnyObject) -> Int {
return 3
}
hoge("a")
hoge("a" as NSString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.