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
struct Car: Drivable { | |
let numberOfWheels = 4 | |
func drive() { } | |
} | |
struct Motorcycle: Drivable { | |
let numberOfWheels = 2 | |
let licensePlate = "asdf123" |
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
protocol Drivable { | |
func drive() | |
var numberOfWheels: Int { get } | |
} | |
func startTraveling(with transportation: Drivable) { } | |
func startTraveling<D: Drivable>(with transportation: D) { } | |
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
extension UIColor { | |
convenience init? (fromHex hex: String) { | |
let hexPattern = try! NSRegularExpression(pattern: "^[0-9a-fA-F]{6}$", | |
options: [.anchorsMatchLines]) | |
let range = NSRange(location: 0, length: hex.characters.count) | |
guard hexPattern.matches(in: hex, | |
options: [], | |
range: range).count == 1 | |
else { return nil } |
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
// | |
// main.m | |
// variable2 | |
// | |
// Created by Varindra Hart on 6/4/15. | |
// Copyright (c) 2015 Varindra Hart. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// | |
// main.m | |
// 12DaysOfChristmas | |
// | |
// Created by Varindra Hart on 6/4/15. | |
// Copyright (c) 2015 Varindra Hart. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
NewerOlder