This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct KeepsOrder: Codable { | |
let name: String | |
let order: [Int] | |
init(name: String) { | |
self.name = name | |
order = [1,2,3,4,5].shuffled() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let string = "one" | |
switch string { | |
case _ where string.contains("one"): | |
break | |
case _ where string.contains("two"): | |
break | |
default: | |
break | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func clearItems() { | |
// clear items | |
} | |
func reloadItems(_ clearItems: (() -> Void)? = nil) { | |
if let _ = clearItems?() { // This will execute the closure if it is not nil and bind its return to _. | |
// Dome something if caller wants to clear items | |
} | |