首页 > 代码库 > Swift-3-字符串和字符
Swift-3-字符串和字符
// Playground - noun: a place where people can playimport UIKitvar someString = "some string literal value"someString += "another"// 初始化空字符串 2种方式,得出的结果一致var emptyString = ""var anotherEmptyString = String()if emptyString.isEmpty { println("emptyString is empty")}// 可变字符串var varibleString = "hosrse"varibleString += "and carriage"let constantString = "hignlander"//constantString += "anything" // 字符串常量不能修改,出错// swift中字符串是值类型 value type// 连接字符串var string1 = "hello"var string2 = " there"var welcome = string1 + string2// 向字符串后添加字符let exclamationMark : Character = "!"welcome.append(exclamationMark)// 字符串插值 \()let multiplier = 3let message = "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)"
Swift-3-字符串和字符
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。