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 UIKit | |
/// MissingHashMarkAsPrefix: "Invalid RGB string, missing '#' as prefix" | |
/// UnableToScanHexValue: "Scan hex error" | |
/// MismatchedHexStringLength: "Invalid RGB string, number of characters after '#' should be either 3, 4, 6 or 8" | |
public enum UIColorInputError: Error { | |
case missingHashMarkAsPrefix | |
case unableToScanHexValue | |
case mismatchedHexStringLength | |
case outputHexStringForWideDisplayColor |
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 | |
// MARK: - What are the Loops | |
// arr = [1,2,3,4,5] -> print(arr[0]), print(arr[1] | |
// MARK: - For-In Loops | |
let names = ["Ahmed", "Mohamed", "Menaim", "Mahmoud"] | |
for name in names { // name is a container |
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 | |
// MARK: - What is the dictionary !? | |
// [Key -> Unique : Value] => Key is int , Value is String, Unsorted (Unarranged) | |
// MARK: - Creating a Dictionary | |
var dict: [Int : String] = [:] | |
var newDict = [12893483 : "Ahmed Menaim", 13713621: "Menaim"] |
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 | |
// MARK: - What is the Set !? | |
// Unarranged list , perform operations, | |
// MARK: - Create Set | |
var letters = Set<Character>() | |
var names: Set<String> = ["ahmed", "mohamed", "Fawzy", "Menaim"] |
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 | |
// MARK: - What is the array !? | |
// -> [] -> Arranged -> [1,2,3,4] var a = 1, var b = 2 var array = [] | |
// MARK: - Create Array | |
//var stringsArray = [] // -> Will give us an error |
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 | |
// MARK: - Comparison Operators < > == != >= <= | |
let number = 8 | |
if number >= 5 { // if number = 5 or number > 5 | |
print(number) | |
} |
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 | |
let number = 5 | |
switch number { // if number | |
case 5: // number == 5 | |
print("Done") | |
case 6: // else if number == 6 | |
print("\(number) is done") |
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 UIKit | |
var greeting = "Hello, playground" | |
let number = 6 | |
if number == 5 { // equal comparison | |
print ("Number is correct") | |
} | |
else if number == 6 { |
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 | |
// MARK: - Assignment Operator = | |
var a = 15 | |
var b = 5 | |
// MARK: - Arithmetic Operators + - * / | |
print(a+b) | |
print(a-b) | |
print(a*b) |
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 | |
var stringNumber: String? // We can identify any optional variable using -> ? | |
var number = 5 | |
//print(Int(stringNumber!)! + number) // Force unwrapping -> ! = Make sure that I have a value here |
NewerOlder