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 latitude = 34.9010 // Always Double | |
let distance = 10 * 0.1490 // Double too |
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 decimalInteger = 17 | |
let binaryInteger = 0b10001 // 17 in binary notation | |
let octalInteger = 0o21 // 17 in octal notation | |
let hexadecimalInteger = 0x11 // 17 in hexadecimal notation |
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 twoThousand: UInt16 = 2_000 | |
let one: UInt8 = 1 | |
let twoThousandAndOne = twoThousand + UInt16(one) |
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
typealias BitRate = UInt | |
typealias AnimationCompletion = ((Bool) -> Void) | |
let maxRate: BitRate = 44100 | |
let fadeInCompletion: AnimationCompletion = { success in | |
print("success: \(success)") | |
} |
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 anonimusCoordinateTuple = (12.4567, 45.9087) | |
print("coordiate: \(anonimusCoordinateTuple.0), \(anonimusCoordinateTuple.1)") | |
let namedCoordinateTuple = (latitude: 12.4567, longitude: 45.9087) | |
print("coordiate: \(namedCoordinateTuple.latitude), \(namedCoordinateTuple.longitude)") | |
typealias Coordinate = (latitude: Float, longitude: Float) | |
let typealiaseCoordinateTuple = (latitude: 12.4567, longitude: 45.9087) | |
print("coordiate: \(typealiaseCoordinateTuple.latitude), \(typealiaseCoordinateTuple.longitude)") |
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
var (latitude, longitude) = anonimusCoordinateTuple | |
print("latitude var: \(latitude)") // latitude var: 12.4567 | |
print("longitude var: \(longitude)") // longitude var: 45.9087 | |
// And small trick to change 2 var between them | |
(longitude, latitude) = anonimusCoordinateTuple | |
print("latitude var: \(latitude)") // latitude var: 45.9087 | |
print("longitude var: \(longitude)") // longitude var: 12.4567 |
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
// MARK: - UIViewControllerTransitioningDelegate | |
extension PaymentInformationRouter: UIViewControllerTransitioningDelegate { | |
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { | |
return HalfSizePresentationController(presentedViewController: presented, presenting: presenting) | |
} | |
} | |
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
enum EventType: Int { | |
case shared = 0 | |
case personal | |
case group | |
} | |
let type = EventType(rawValue: -1) | |
// type is inferred to be of type "EventType?", or "optional EventType" |
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
if type != nil { | |
print("type of \(type!.rawValue).") | |
} | |
// Prints "type of 1." |
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
if let type = EventType(rawValue: -1) { | |
print("type of: \(type)") | |
} else { | |
print("type is nil") | |
} |