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 nameYourMom: String? = "" | |
let forcedString: String = nameYourMom? | |
if nameYourMom != nil { | |
print("Your mom, \(nameYourMom!), is a bitch") | |
} else { | |
print("Please write your mother's name") | |
} |
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 name = "Тарас" | |
// | |
var poka = true | |
if name == "Тарас" { | |
poka = true | |
} else { | |
poka = !poka | |
} | |
var poshel = " ,fuck off" |
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 totalRent: Double = 5340 | |
let electricityRepairCost: Int = 414 | |
let electricityBill: Double = 1241 | |
let waterBill: Double | |
let arnonaBill: Double | |
let cleaningBill: Double | |
//struct Rent { |
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
var billElectricity: Double = 1241.7 | |
let repair: Double = 414 | |
let quantityRoomate: Double = 3 | |
let fourMonth: Double = 4 | |
let olegLived: Double = 3 | |
var taras: Double = ((1241.7 - repair)/fourMonth)/quantityRoomate | |
billElectricity -= taras |
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 totalRent = 5300 | |
let electrecityBills = 1241 | |
let arnonaBill = 153 | |
var roomates = 3 | |
let repairBill = 414 | |
var month = 0 | |
func electrecity(_ name: String) -> String { |
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
class SurveyQuestion2 { // сделали класс | |
let text: String // внесли константу задали ей тип | |
var response: String? // внесли переменную, задали ей тип , который может быть пустым nil | |
init(text: String) { // задалаи проперти константе | |
self.text = text // задали, что text (который init(text: String)) берет значение text (который let) | |
} | |
func ask() { // сделали функцию , задача которой печать то, что находиться в text | |
print(text) | |
} | |
} |
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
struct Rectangle { | |
var width: Double = 10 | |
var area: Double = 100 | |
var height: Double { | |
get { | |
return area / width | |
} | |
set (height) { |
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
var array = ["One", "Two", "Three"] | |
array.append("Four") | |
// This won't compile, since the above array is specialized | |
// for strings, meaning that other values can't be inserted: | |
array.append(5) | |
// As we pull an element out of the array, we can still treat | |
// it like a normal string, since we have full type safety. | |
let characterCount = array[0].count |
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
func swapTwoString(a: inout String, b: inout String) { | |
let temporaryB = a | |
a = b | |
b = temporaryB | |
} | |
var someString = "I AM FIRST" | |
var anotherStirng = "I AM SECONDE" |
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
struct Siblings { | |
var sibling1: Int | |
var sibling2: Int | |
init(sibling1: Int, sibling2: Int){ | |
self.sibling1 = sibling1 | |
self.sibling2 = sibling2 | |
} |
OlderNewer