let num = 97
UnicodeScalar(num)! // a
var char = "A"
UnicodeScalar(char)!.value // 65
var swiftStr = "#Swift!"
swiftStr.trimmingCharacters(in: ["#","!"]) // Swift
var str = "He!llo~!@@@, JAE@EUN"
str.components(separatedBy: ["~","!","@",","]) // ["He", "llo", "", "", "", "", "", " JAE", "EUN"]
str.components(separatedBy: ["~","!","@",","]).joined() // Hello JAEEUN
var text = "ABCA"
text.replacingOccurrences(of: "A", with: "B") // BBCB
let text = "abcde"
text.prefix(2) // ab
text.suffix(2) // de
let today = Date()
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone.current
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss z"
dateFormatter.string(from: today) // 2019-10-24 04:58:31 GMT+9
let num = 123456789
let digits = String(num).compactMap{ $0.wholeNumberValue } // [1, 2, 3, 4, 5, 6, 7, 8, 9]
let num = 10.5
let num2 = 10.0
ceil(num) // 11.0
ceil(num) // 10.0
let num = 10.5
floor(num) // 10.0
let num = 10.5
round(num) // 11.0
let num = 10.5
sqrt(num) // 3.24037034920393
끝자리에서 반올림 됨
String(format: "%.4f", 1.234567) // 1.2346
while let input = readLine() {
print(input)
}
let text = "111"
Int(text, radix: 2)! // 7
let num = 1000
String(num, radix: 2) // 1111101000
String(num, radix: 16) // 3e8
String(num, radix: 16, uppercase: true) // 3E8