Skip to content

Instantly share code, notes, and snippets.

View vialyx's full-sized avatar
🎯
Focusing

Maxim Vialyx vialyx

🎯
Focusing
View GitHub Profile
let latitude = 34.9010 // Always Double
let distance = 10 * 0.1490 // Double too
let decimalInteger = 17
let binaryInteger = 0b10001 // 17 in binary notation
let octalInteger = 0o21 // 17 in octal notation
let hexadecimalInteger = 0x11 // 17 in hexadecimal notation
let twoThousand: UInt16 = 2_000
let one: UInt8 = 1
let twoThousandAndOne = twoThousand + UInt16(one)
typealias BitRate = UInt
typealias AnimationCompletion = ((Bool) -> Void)
let maxRate: BitRate = 44100
let fadeInCompletion: AnimationCompletion = { success in
print("success: \(success)")
}
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)")
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
// MARK: - UIViewControllerTransitioningDelegate
extension PaymentInformationRouter: UIViewControllerTransitioningDelegate {
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
return HalfSizePresentationController(presentedViewController: presented, presenting: presenting)
}
}
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"
if type != nil {
print("type of \(type!.rawValue).")
}
// Prints "type of 1."
if let type = EventType(rawValue: -1) {
print("type of: \(type)")
} else {
print("type is nil")
}