Last active
September 1, 2015 10:52
-
-
Save sonsongithub/5f197158dcda14088697 to your computer and use it in GitHub Desktop.
Code snippets for Swift symposium #2
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
// 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