Swift Tutorial - Tutorialspoint
When we run above program using playground, we get following result true The initial array to be sorted for icecream is given as ...
println(descending) println(ascending) When we run the above program using playground, we get the following result: [75, 20, 10, ...
argument names will be derived. Since the shorthand argument is defined in expression body the 'in' keyword is omitted. Closures ...
When we run the above program using playground, we get the following result: [NO, EA, WE, SO] Capturing Values and Reference Typ ...
When we run the above program using playground, we get the following result: 82 64 46 When each and every time the outer functio ...
An enumeration is a user-defined data type which consists of set of related values. Keyword enum is used to defined enumerated d ...
switch lang { case .Swift: println("Welcome to Swift") case .Closures: println("Welcome to Closures") default: println("Introduc ...
case .India: println("Climate is Hot") case .America: println("Climate is Cold") case .Africa: println("Climate is Moderate") ca ...
var studDetails = Student.Name("Swift") var studMarks = Student.Mark( 98 , 97 , 95 ) switch studMarks { case .Name(let studName) ...
let yearMonth = Month.May.rawValue println("Value of the Month is: \(yearMonth).") When we run the above program using playgroun ...
Swift provides a flexible building block of making use of constructs as Structures. By making use of these structures once can d ...
struct studentMarks { var mark1 = 100 var mark2 = 200 var mark3 = 300 } let marks = studentMarks() println("Mark1 is \(marks.mar ...
Best Usage Practices of Structures Swift language provides the functionality to define structures as custom data types for build ...
Another Example struct markStruct{ var mark1: Int var mark2: Int var mark3: Int init(mark1: Int, mark2: Int, mark3: Int){ self.m ...
Classes in Swift are building blocks of flexible constructs. Similar to constants, variables and functions the user can define c ...
var mark: Int var mark2: Int } The syntax for creating instances let studrecord = student() Example class MarksStruct { var mark ...
var mark1 = 300 var mark2 = 400 var mark3 = 900 } let marks = studentMarks() println("Mark1 is \(marks.mark1)") println("Mark2 i ...
let spClass1 = SampleClass(s: "Hello") let spClass2 = SampleClass(s: "Hello") spClass1 === spClass2 // false println("\(spClass1 ...
Swift language provides properties for class, enumeration or structure to associate values. Properties can be further classified ...
println("\(n.digits)") println("\(n.pi)") When we run the above program using playground, we get the following result: 67 3.1415 ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf