Swift Optional Chaining
Optional Chaining class Address { var buildingName: String? } class Person { var address: Address? } func createBuildingName() -> String { print("createBuildingName was called.") return "...
Optional Chaining class Address { var buildingName: String? } class Person { var address: Address? } func createBuildingName() -> String { print("createBuildingName was called.") return "...
Optional Chaining const adventurer = { name: "Alice", cat: { name: "Dinah" } } function* createName() { return "12" } console.log(adventurer.dog?.name); // undefined adventurer.dog?.name...
The simplest generator is a cell that yields a single value.
var str = "123ABC456 789abc012" _ = str.replacingOccurrences(of: "[a-zA-Z]", with: "-", options: .regularExpress, range: nil) // output // 123---456 789---012
git checkout -b Lesson4 origin/Lesson4 如果只是單純 checkout: git checkout origin/Lesson4 就會產生以下警告: Note: checking out 'origin/Lesson3'. You are in 'detached HEAD' state. You can look around, make...
git clone --branch Lesson4 https://github.com/chiahao/Memorize.git
git checkout -b Lesson4 origin/Lesson4
Escaping Closures A closure is said to escape a function when the closure is passed as an argument to the function, but is called after the function returns. As an example, many functions tha...
protocol protocol inheritance protocol Moveable { } protocol Vehicle: Movable { } class Car: Vehicle { // 要實作 Movable、Vehicle } Very rarely, a protocol can be used as a type (in any other...
Clean the Code EmojiMemoryGame.swift typealias Card = MemoryGame<String>.Card private(set) var cards: Array<Card> ... cards = Array<Card>() cards = [] Computed Property ...