数据类型

This commit is contained in:
2021-12-03 12:04:57 +08:00
parent e7c05694a9
commit 319a295816
10 changed files with 171 additions and 13 deletions

View File

@@ -1,3 +0,0 @@
import UIKit
var greeting = "Hello, playground"

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true' executeOnSourceChanges='false' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>

View File

@@ -0,0 +1,25 @@
import UIKit
//
//
/**
*/
/**
1.
/**/
2.
*/
// markdown
//: #
/*:
# Swift
##
-
-
*/
//: [Next](@next)

View File

@@ -0,0 +1,116 @@
//: [Previous](@previous)
//: ###
// let
// 使
let age: Int
age = 31
let name = "Zhang Mengxu"
let sex: String = "man"
//: ###
// 使
//
//: ###
/*:
:
- value type
- reference type
value type
- enum:
Optional
- struct:
BoolIntFloatDoubleCharacterStringArrayDictionarySet
reference type
:
- class
*/
//: ####
/*:
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64
32bitIntInt32, IntInt64
UInt8.max Int16.min
使Int
*/
let a:Int = 10
print(Int.max)
//: ####
/*:
Float,326Double6415
*/
let letFloat:Float = 30.0
let letDouble:Double = 30.0
//: ####
//
let bool = true
//
let string = "Zhang Mengxu"
//
let character: Character = "🐶"
//
let intDecimal = 17 //
let intBinary = 0b1001 //
let intOctal = 0o21 //
let intHexadecimal = 0x11 //
//
let doubleDecimal = 125.0 // 1.25e2 0.0125 1.25e-2
let doubleHexadecimal1 = 0xFp2 //15x2^260.0
let doubleHexadecimal2 = 0xFp-2 // 15x2^-23.75
//
let array = [1, 3, 5, 7]
//
let dictionary = ["name": 34, "age": 18]
//: ####
//
let int1: UInt16 = 2_000
let int2: UInt8 = 1
let int3 = int1 + UInt16(int2)
//
let int = 3
let double = 0.14159
let pi = Double(int) + double
let intpi = Int(pi)
//: #### tuple
//
let httpError = (404, "Not Found")
// 访
httpError.0
httpError.1
print("The status code is \(httpError.0)")
//
let (statusCode, statusMessage) = httpError
print("The status message is \(httpError.1)")
// -Not Found
let (justTheStatusCode, _) = httpError
// ,使访
let http200Status = (statusCode: 200, description: "ok")
print("The status code is \(http200Status.statusCode)")
//: [Next](@next)

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='raw' buildActiveScheme='true' importAppTypes='true'>
<pages>
<page name='01 注释'/>
<page name='02 数据类型'/>
</pages>
</playground>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SwiftStudy (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>