To be answered

Ternary, Nil-Coalescing, Range, and Logical operators in Swift

let x = true let y = false let z = x && y || x print(z)

let colorName: String? = “blue” let defaultColor = “red” let finalColor = colorName ?? defaultColor

let contentHeight = 40 let hasHeader = true let rowHeight = contentHeight + (hasHeader ? 50 : 20)

let range = …5 print(range.contains(4)) print(range.contains(7))

let names = [“Anna”, “Alex”, “Brian”, “Jack”] let count = names.count for i in 2..<count { print(names[i]) }

let range = ..<5 print(range.contains(5))

let names = [“Alice”, “Bob”, “Charlie”, “David”, “Eve”] let selectedNames = names[1…3] print(selectedNames.count)

Subscribe to our newsletter