Filters

Hide filters
Platform
Content Type
Difficulty

All Tutorials · 9 Results

Contained in: Swift Apprentice: Fundamentals combine
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Strings

…single character to represent é is code point 233. The two-character case is an e on its own, followed by an acute accent combining character, a special character that modifies the previous character. So you can represent the e with an acute accent by either of these means…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Basic Control Flow

There’s also an operator that lets you test if a value is less than or equal to another value: <=. It’s a combination of < and == and will return true if the first value is either less than the second value or equal to it. Similarly, there…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Types & Operations

…much more than create simple strings. Sometimes you need to manipulate a string, and one common way to do so is to combine it with another string. In Swift, you do this in a rather simple way: by using the addition operator. Just as you can add numbers…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Enumerations

…machines that dispense soda when the customer deposits the proper amount of money. Elevators that drop riders off at upper floors before going down. Combination locks that require combination numbers in the proper order. To operate as expected, these devices depend on an enumeration’s guarantee that they will only…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Protocols

…behind hash values is quite complex, but you can let Swift handle the details. Make sure that everything you include in the == comparison is combined using the hasher. For example: class Student { let email: String let firstName: String let lastName: String init(email: String, firstName: String, lastName: String) { self.email = email…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Arrays, Dictionaries & Sets

…characters. For example, for the dictionary ["NY": "New York", "CA": "California"], the output would be California. Challenge 9: Merge Dictionaries Write a function that combines two dictionaries into one. If a certain key appears in both dictionaries, ignore the pair from the first dictionary. This is the function’s signature…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Optionals

This code unwraps two values. It will only execute the if part of the statement when both optionals contain a value. You can combine unwrapping multiple optionals with additional Boolean checks. For example: if let authorName = authorName, let authorAge = authorAge, authorAge >= 40 { print("The author is \(authorName…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Expressions, Variables & Constants

These compute the maximum and minimum of two numbers, respectively. If you’re particularly adventurous, you can even combine these functions like so: max((2.0).squareRoot(), Double.pi / 2) // 1.570796326794897 Naming Data At its simplest, computer programming is all about manipulating data. Remember, everything you see on your screen…
iOS & Swift

Chapter in Swift Apprentice: Fundamentals

Structures

This block of code demonstrates the basic syntax for defining a structure. In this case, the code declares a type named Location that combines x and y coordinates. The basic syntax begins with the struct keyword followed by the name of the type and a pair of curly braces. Everything…