This file contains 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
// Source: https://docs.swift.org/swift-book/ReferenceManual/Patterns.html#grammar_optional-pattern | |
let arrayOfOptionalInts: [Int?] = [nil, 2, 3, nil, 5] | |
for case let number? in arrayOfOptionalInts { | |
print("Found a \(number)") | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 MapKit | |
import PlaygroundSupport | |
let mapView = MKMapView() | |
PlaygroundPage.current.liveView = mapView | |
CLGeocoder().geocodeAddressString("1 Apple Park Way, Cupertino, CA") { | |
(places, _) in | |
guard let places = places?.map(MKPlacemark.init) else { return } | |
mapView.showAnnotations(places, animated: true) |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains 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
Africa/Abidjan | |
Africa/Accra | |
Africa/Addis_Ababa | |
Africa/Algiers | |
Africa/Asmara | |
Africa/Bamako | |
Africa/Bangui | |
Africa/Banjul | |
Africa/Bissau | |
Africa/Blantyre |
This file contains 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 | |
extension String { | |
var guessedNameFromEmail: String? { | |
return self.split(separator: "@").first?.split(separator: ".").map { $0.capitalized(with: Locale.autoupdatingCurrent) }.joined(separator: " ") | |
} | |
} |
This file contains 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
DEVICE TYPE | PRODUCT NAME | |
---|---|---|
iPhone1,1 | iPhone | |
iPhone1,2 | iPhone 3G | |
iPhone2,1 | iPhone 3GS | |
iPhone3,1 | iPhone 4 (GSM) | |
iPhone3,2 | iPhone 4 (GSM, Revision A) | |
iPhone3,3 | iPhone 4 (CDMA) | |
iPhone4,1 | iPhone 4S | |
iPhone5,1 | iPhone 5 (A1428) | |
iPhone5,2 | iPhone 5 (A1429) |
This file contains 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
#!/bin/sh | |
git bundle create ~/Backups/`basename $PWD`.git --all |
This file contains 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
localeIdentifier | Description | |
---|---|---|
eu | Basque | |
hr_BA | Croatian (Bosnia & Herzegovina) | |
en_CM | English (Cameroon) | |
en_BI | English (Burundi) | |
en_AE | English (United Arab Emirates) | |
rw_RW | Kinyarwanda (Rwanda) | |
ast | Asturian | |
en_SZ | English (Eswatini) | |
he_IL | Hebrew (Israel) |
This file contains 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 triangularNumbers = sequence(state: (0,0)) { (state: inout (Int,Int)) -> Int in | |
state = (state.0 + 1, state.1 + state.0 + 1 ) | |
return state.1 | |
} |
This file contains 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 pascalsTriangle = sequence(first: [1]) { | |
zip([0] + $0, $0 + [0]).map(+) | |
} |
NewerOlder