Swift 基本数据类型,常/变量声明(一)
发布时间:2020-12-14 07:10:02 所属栏目:百科 来源:网络整理
导读:https://github.com/Zhangjingwang1993/Swift.git /// 项目不太忙,撸撸Swift 变量 使用var声明 var str :String = "dd" str = "GG" print( str ) 常量 使用let声明 let count: Int = 16 print (count) 整型 Int ,Int8,Int16,Int32,Int64UInt,UInt8,UInt16,UI
https://github.com/Zhangjingwang1993/Swift.git 变量 使用var声明var str:String = "dd"
str = "GG"
print(str)
常量 使用let声明let count:Int = 16
print(count)
整型Int,Int8,Int16,Int32,Int64
UInt,UInt8,UInt16,UInt32,UInt64
浮点型,布尔型Float,Double,Bool
获取字符串的数量 // str = GGprint(str.characters.count) // 2
检查字符串是否有特定的前缀和后缀 pre/suflet sttPre = "hello.com"
if sttPre.hasSuffix(".com33"){
print("YES")
}else{
print("NO")
}
还可以”()”let name1 = "helloworld"
let msg = "Welcome to (name1)"
print(msg) // Welcome to helloworld
大小写转换通过字符串的uppercaseString、lowercaseString、capitalizedString
属性来访问一个字符串的大写/小写/首字母大写
字符var char:Character = "$"
print(char)
元组let myCode = (one:"ZJwang",two:123)
print("(myCode.one)")
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |