Book Image

Mastering Swift 3 - Linux

By : Jon Hoffman
Book Image

Mastering Swift 3 - Linux

By: Jon Hoffman

Overview of this book

Swift is a modern, fast, and safe programming language created by Apple. Writing Swift is interactive and fun, the syntax is concise yet expressive, and the code runs lightning-fast. Swift’s move to open source has been embraced with open arms and has seen increased adoption in the Linux platform. Our book will introduce you to the Swift language, further delving into all the key concepts you need to create applications for desktop, server, and embedded Linux platforms. We will teach you the best practices to design an application with Swift 3 via design patterns and Protocol-Oriented Programming. Further on, you will learn how to catch and respond to errors within your application. When you have gained a strong knowledge of using Swift in Linux, we’ll show you how to build IoT and robotic projects using Swift on single board computers. By the end of the book, you will have a solid understanding of the Swift Language with Linux and will be able to create your own applications with ease.
Table of Contents (24 chapters)
Mastering Swift 3 - Linux
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Learning About Variables, Constants, Strings, and Operators

Summary


While the concept of optional types, as used in the Swift language, might seem a little foreign at first, the more you use them, the more they will make sense. One of the biggest advantages with optional types is we get additional compile time checks that alert us if we forget to initialize non-optionals prior to using them.

The one thing to take away from this chapter is the concept of what optionals are. To reinforce this concept, let's review a couple of paragraphs from this chapter.

It is very important to understand that nil in Swift is very different than nil in Objective-C or other C-based languages. In Objective-C, nil is a pointer to a non-existent object; however, in Swift, nil is an absence of a value. Knowing this concept is very important in fully understanding optionals in Swift.

A variable defined as an optional can contain a valid value or it can have no value. We set a variable to a valueless state by assigning it Swift's special nil value. Optionals of any type can...