Created
August 24, 2021 09:11
-
-
Save ksloginov/767f6a8e37cdddb0e63e0c419a38c461 to your computer and use it in GitHub Desktop.
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 | |
// | |
////Hvilken type er `value`? | |
// | |
//let value0 = 42 | |
// | |
//var value1: String = "10" + "lsddsakndas njk" | |
//value1 += "dfklmf" | |
// | |
//let value2: Int = 10 | |
// | |
//let value3 = 10.0 | |
// | |
//let value4: Array<String> = ["1", "2", "3"] | |
//let arr: [String] = ["1", "2", "3"] | |
//let arr33 = ["1", "2", "3"] | |
// | |
// | |
//let value5: Set<String> = Set(arr) | |
//let value6_2 = Set(arrayLiteral: "1", "2", "3") | |
// | |
//let value6 = Set(arrayLiteral: 1, 2, 3) | |
// | |
//let value7: [String: Int] = ["a": 42] | |
// | |
//var value7_not_use_it_like_this = Dictionary<String, Int>() | |
//value7_not_use_it_like_this["a"] = 42 | |
//// | |
// | |
// | |
// | |
//// Kompilerer det? Hvorfor ja? Hvorfor nei? Forklar! | |
//// | |
//// | |
/////let value2: String = 42 | |
//// | |
////let value3 = 10.0 + 10 // Double! | |
////// | |
////let value4 = 10 + Int(truncating: true) | |
////// | |
//////let value5 = "10" + "10" | |
////// | |
////let value5 = "10" + "Monday" | |
//// | |
//let answer6 = true, wrongAnswer = false | |
//// | |
//let answer7 = true, value = 42, film = "Inside" | |
//// | |
//// | |
//// | |
////8. | |
//// | |
////var value8 = 42 | |
//// | |
//// value8 += 1 | |
//// | |
//// | |
//// | |
////let value9 = (4 * 5) / 0 | |
//// | |
////var value10 = Set(["1"]).union(Set(["1"])) | |
////value10.insert("1") | |
////value10.insert("2") | |
////value10 | |
//// | |
//let value11 = ["1"] + [] | |
//// | |
//let value12 = ["1"] + [2] | |
//// | |
//// | |
//// | |
////13. | |
//// | |
// let set1 = Set(arrayLiteral: 1, 2, 3, 4, 5) | |
// | |
// let set2 = Set(arrayLiteral: 4, 5, 6) | |
// | |
//let set = set1.union(set2) //-> 1,2,3,4,5,6 | |
//// | |
//// | |
////var a = "key" | |
////let value14 = [a: 42] | |
////// | |
// | |
//var value15 = ["b": 42] | |
//value15["b"] = nil | |
//value15.count | |
// | |
// | |
//// | |
//let value16 = ["a": 42, "b": true] as [String : Any] | |
//// | |
////let value17 = ["a": 42, "b": true] as [String : Any] | |
//// | |
////let value18 = ["a": nil, "a": 42] | |
// | |
// | |
//let str = "What a day" | |
//let detailsStr = "Today is Monday; Status = \(str)" | |
//print(detailsStr) | |
// | |
//let digit: Int = 42 | |
//let detailsStr2 = "Favorite number: \(digit)" | |
//print(detailsStr2) | |
// | |
// | |
// | |
//let a = 42 | |
//let doubleA = Double(a) | |
//let doubleA_2 = a as? Double | |
// | |
// | |
// | |
//let floatNumber = 3.9 | |
//let intFraFloat = Int(3.9) | |
// | |
// | |
// | |
//var position = (5, 4, z: 4) | |
//position.z | |
// | |
// | |
//print(position.1) // <-- prints 5 | |
// | |
// | |
// | |
// | |
// | |
// | |
//let http404Error = (404, "Not Found") | |
//// http404Error is of type (Int, String), and equals (404, "Not Found") | |
// | |
//let (_, error) = http404Error | |
////print("The status code is \(justStatusCode)") | |
//print(error) | |
// | |
enum Class { | |
case Teacher(name: String) | |
case Student(name: String) | |
case Macbook | |
} | |
let studentA = Class.Student(name: "Student A") | |
let teacherA = Class.Teacher(name: "Konstantin") | |
//... | |
var someone = teacherA | |
switch someone { | |
case .Student(let name): | |
if name.count > 4 { | |
print(name) | |
} | |
default: | |
print("Something strange") | |
} | |
// | |
// | |
// | |
// | |
////val a = if (hasGrade) 5.0 else 2.0 | |
//let hasGrade = !false //== true | |
//let hasFinishedClass = false | |
//let aaaa = hasGrade ? 5.0 : (hasFinishedClass ? 0.0 : 2.0) | |
// | |
// | |
//let rem = 5 % 2 | |
// | |
//var aaaaaa = 2 | |
//aaaaaa = aaaaaa + 1 | |
//aaaaaa /= 1 | |
// | |
// | |
// | |
//let names = ["Anna", "Alex", "Brian", "Jack", "Joye"] | |
//for i in { | |
// print(names[i]) | |
//} | |
// | |
let animals = ["Dog", "Cat", "Teacher", "Squirrel"] | |
for animal in animals { | |
print("My #?????? favorite animal: \(animal)") | |
} | |
for i in 0..<animals.count { | |
print("My #\(i + 1) favorite animal: \(animals[i])") | |
} | |
for i in animals.indices { | |
print("My #\(i + 1) favorite animal: \(animals[i])") | |
} | |
func increment(value: Int, by n: Int) -> Int { | |
return value + n | |
} | |
increment(value: 42, by: 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment