let constant = 10 var number = 10 var result = number + constant
//constant = 20 // Cannot assign to value: 'constant' is a 'let' constant
number = 50
var message = "The best way to get started is to stop talking and code."
var greeting = "Hello " var name = "Yofer" message = greeting + name
message.uppercased() message.lowercased()
message.count
var bookPrice = 39 var numOfCopies = 5 var totalPrice = bookPrice * numOfCopies //var totalPriceMessage = "The price of the book is $" + totalPrice // Binary operator '+' cannot be applied to operands of type 'String' and 'Int'
var totalPriceMessage = "The price of the book is $" + String(totalPrice)
totalPriceMessage = "The price of the book is $\(totalPrice)"
var timeYouWakeUp = 6
if timeYouWakeUp == 6 { print("Cook yourself a big breakfast") } else { print("Go out for breakfast") }
switch timeYouWakeUp { case6: print("Cook yourself a big breakfast") default: print("Go out for breakfast") }
var bonus = 5000
if bonus >= 10000 { print("I will travel to Paris and London!") } elseif bonus >= 5000 && bonus < 10000 { print("I will travel to Tokyo") } elseif bonus >= 1000 && bonus < 5000 { print("I will travel to Bangkok") } else { print("Just stay home") }
do { var bonus = 5000 // Variable 'bonus' was never mutated; consider changing to 'let' constant switch bonus { case10000...: print("I will travel to Paris and London!") case5000...9999: print("I will travel to Tokyo") case1000...4999: print("I will travel to Bangkok") default: print("Just stay home") } }
//var bookCollection = ["Tool of Titans", "Rework", 1] // error: heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional
var bookCollection = ["Tool of Titans", "Rework", "Your Move"]