尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

day2: booleans, string interpolation, and checkpoint1

day2: booleans, string interpolation, and checkpoint1 import Cocoa //boolean let goodDogs true let gameOver false let isMultiple 120.isMultiple(of:3) var isAuthenticated false isAuthenticated !isAuthenticated //toggle函数:is the same as using the exclamation mark for not just in slightly less code but is surprisingly useful when dealing with complex numbers var game false game.toggle() //join strings together //one way: join them using plus (operator overloading); this way is wasteful let firstPart Hello, let secondPart World! let geeting firstPart secondPart let geetingForPeople geeting Girls and boys! //another way: a special technique called string interpolation //you cant add integers to string with plus but string interpolation can let name Taylor let age 26 let message Hello, my name is \(name) and Im \(age) years old. //checkpoint 1 let tem 10 let fahrenheit (tem * 9)/5 32 print(celsius is \(tem) and fahrenheit is \(fahrenheit))
返回列表