前端之家收集整理的这篇文章主要介绍了
swift (一),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
println( "Hello world" )
let loginCount = 5
var currentLoginCount = 0
println((loginCount,currentLoginCount))
let a = 1,b = 2,c = 3
var x = 4,y = 5,z = 6
var str1 = "str1",str2 = "str2",str3 = "str3"
var nameString: String
nameString = "cacaca"
println((nameString))
let 王 = "高富帅"
var �� = "☺"
let a2b2 = 123;
println((��))
println(王)
var juiceName = "apple Juice"
println((juiceName))
println(("I Love \(juiceName)"))
var iosDevice = "iPhone6"
println("I want to \(iosDevice) ぁゅゐ ��")
这是第二个多行注释的结尾
这是第一个多行注释的结尾
*/
var �� = "Rubbit"; println(��)
let adb = 10; println((adb));
let minInt8 = Int8.min
let maxInt8 = Int8.max
println((minInt8,maxInt8))
let minUint8 = UInt8.min
let maxUint8 = UInt8.max
println((minUint8,maxUint8))
let minInt16 = Int16.min
let maxInt16 = Int16.max
println((minInt16,maxInt16))
let minUint16 = UInt16.min
let maxUint16 = UInt16.max
println((minUint16,maxUint16))
let minInt32 = Int32.min
let maxInt32 = Int32.max
println((minInt32,maxInt32))
let minUint32 = UInt32.min
let maxUint32 = UInt32.max
println((minUint32,maxUint32))
let minInt64 = Int64.min
let maxInt64 = Int64.max
println((minInt64,maxInt64))
let minUint64 = UInt64.min
let maxUint64 = UInt64.max
println((minUint64,maxUint64))
var π:Float
π = 3.1415926
println((π))
var π1:Double
π1 = 3.1415926535897932384
println((π1))
var str = "iPhone"
var value = 10
let pdsu = 5 + 1.442
let value1:UInt16 = 3200
let value2:UInt8 = 7
let value3 = value1 + UInt16(value2)
println((value3))
var one = 25
var two = 3.13
var three = Double(one) + two
println((three))
typealias audioSample = Int
let maxValue = audioSample.max
println(maxValue)
let areYouOk = true
let areYouLikeShit = false
if areYouOk {
println((areYouOk))
}
if !areYouLikeShit {
println((areYouLikeShit))
}
let http404Error = (404,"Not Found !")
let (messageCode,message) = http404Error
println("this is status code \(messageCode)")
println("this is status message \(message)")
println("this is status code \(http404Error.0)")
println("this is status message \(http404Error.1)")
let (justNeedStatusCode,_) = http404Error
println("this is status code \(justNeedStatusCode)")
let (_,justNeedStatusMessage) = http404Error
println("this is status message \(justNeedStatusMessage)")
let http200Status = (statusCode: 200,message: "OK")
println("this is status code \(http200Status.statusCode)")
println("this is status message \(http200Status.message)")
let possableNumber = "123"
let converNumber = possableNumber.toInt()
if let number = possableNumber.toInt() {
println("\(possableNumber) has an integer value of \(number)")
}
else {
println("\(possableNumber) could not convered integer")
}
let age = -3
assert(age >= 0,"A Person's Age Cound not be less than zero")
原文链接:https://www.f2er.com/swift/326620.html