Github : https://github.com/faizanf33/Work-Swift
Slide : https://slides.com/faizanf33/swift
v 4.x
let presenter = "Faizan Ahmad"
print("Hello World!, from \(presenter).")
That's cool huh!
>> Hello World!, from Faizan Ahmad.
SWIFT
A powerful and intuitive programming language (High Level).
Designed for iOS, macOS, watchOS, tvOS, Linux, and z/OS.
Combines the best of C and Objective-C.
Typing is less static, strong and inferred disciplined
class Shape {}
class Circle : Shape {}
class Rectangle : Shape {}
func area (shape: Shape) -> Double {
if shape is Circle { ... }
else if shape is Rectangle { ... }
}
Incomplete (development still in progress by )!
Type_Annotations = 1...5
Int
Float
Double
Bool
String
Operators
=
+ - / * %
+= -= /= *= %=
== != < <= > >=
=== !==
! && ||
... ..<
++
--
Constant -> let
Variable -> var
let intConst : Int = 2147483647
let pi = Float(3.14159)
let doubleConst : Double = 1.8e+308
let setFlag : Bool?
setFlag = True // type(of: setFlag) = Optional<Bool>
let langTrouble : String = "Urdu vs Pashto"
var intVar = Int(2147483647)
var floatVar : Float = 1.7014114943223253963784095737842e+38
var doubleVar : Double = 1.8e+308
var flag : Bool? // flag = nil
var lang : String = "Swift"
Auto Inference -> let || var
let pi = 3.14159 // type(of: pi) = Double
let lang = "Swift" // type(of: lang) = String
var range = 1...5 // type(of: range) = CountableClosedRange<Int>
var list = ["Hello", "World"] // type(of: list) = Array<String>
let tuple = (list, lang, pi) // type(of: tuple) = (Array<String>, String, Double)
let name : Type = value
var name : Type = value
var name = value
Conditional Statements
Loops
Control transfer statements
if condition {...}
else if condition {...}
else {...}
switch value {
case check:
...
default:
...
}
for index in 1...5 {
print(index)
}
while condition {
...
}
repeat {
...
} while condition
Strings
Arrays
Sets
Dictionaries
Functions
Closures
Nested Functions
func someFunc (externalName localName: Type) -> rType {
// function can use localName
}
Github : https://github.com/faizanf33/Work-Swift
Slide : https://slides.com/faizanf33/swift
Thank you for your precious time.
Questions Please !