Control Flow 用 if 和 switch 来做条件语句,并且用for-in,for,while,和do-while做循环,条件和循环的括号是可以不写的,但是body外面的括号是必须写的 let individualScores = [,,,,] var teamScore = for score in individualScores{ { temScore += } else { tempScore += } } teamScore 在 if 语句中,条件必须是一个boolean…
素材:A Swift Tour 推荐下载Playground:Download Playground objc 自己较为熟悉,想熟悉下风头正劲的 swift.就先从官方的入门手册开始撸. 每一小节,我都摘录或总结3个对自己三观冲击最大的[知识点],以方便以后温习.总结不保证绝对正确,仅供交流之用.O(∩_∩)O哈哈~ Simple Values var 表示变量 let 声明常量 [] 用于声明数组和字符串 Control Flow if 或 while 等的判断条件中必须使用布尔值. 判断条件…
import Foundation //*********************************************************************************************** //1.Hello world //_______________________________________________________________________________________________ //输出 "Hello, world&q…
关于Optional的Control Flow if let constantName = someOptional { statements } 如果该Optional为nil,则不进入if,否则执行且constantName为该Optional的值 例子: if let actualNumber = possibleNumber.toInt() { println("\(possibleNumber) has an integer value of \(actualNumber)"…
let Constant var Variable let implicitInteger = 70 let implicitDouble = 70.0 let explicitDouble: Double = 70 The so-called type implications To include value in strings: let fruitSummary = "I have \(apples + oranges) pieces of fruit." Arrays a…
3.8. Control FlowJava, like any programming language, supports both conditional statements and loops to determine control flow. We will start with the conditional statements, then move on to loops, to end with the somewhat cumbersome switch statement…