swift 系统学习 03 三目 区间运算符 开区间 闭区间 和三目类似的还有一个空合/聚合运算符
2017-03-01 14:10
363 查看
/* * 本节内容: * 1.除法 % * 2.&& || * 3.三目 * 4.区间运算符 */ let imZero = 30 let imIntOne = 10.5 imIntOne / Double(imZero) // Swift2.2的语法 // let result = 10 % 2.5 // Swift3.0 let result = 10.0.truncatingRemainder(dividingBy: 2.2) // Swift3.0弃用++ -- var increment = 10 increment += 1 // 登录方式一: var isUserNameOK = false var isPasswordOk = false // 登录方式二: var isPhoneNumberOK = true var isPhoneCodeOK = false if (isUserNameOK && isPasswordOk) || (isPhoneNumberOK && isPhoneCodeOK) { print("Login Successed!") } else { print("Login Failed!") } // 三目 let batteryCapacity = 48 let batteryColor = batteryCapacity <= 20 ? UIColor.yellow : UIColor.green /* * 区间运算符Range Operator * 1.闭区间运算符: x...y * 2.开区间运算符: x..<y */ for index in 1...10 { print("index is \(index)") } for index in 1..<10 { print("index * index is \(index * index)") } // 了解数组: 相同类型 let courses = ["Objective-C", "JavaScript", "Swift", "C", "Java", "Ruby"] for index in 0..<courses.count { print("课程名字: \(courses[index])") }
相关文章推荐
- Swift学习---基础三(区间运算符、控制器转移语句)
- logz.io一个企业级的ELK日志分析器 内部集成了机器学习识别威胁——核心:利用用户对于特定日志事件的反馈处理动作来学习判断日志威胁 + 类似语音识别的专家系统从各方收集日志威胁信息
- Swift学习笔记(十三)——区间运算符和for-in循环
- swift 学习笔记(12)-区间运算符
- swift 系统学习 07 区间 和 switch case
- swift 系统学习 05 聚合(空合)解包 链式解包 可选型和元组的结合
- Swift 学习- 03 -- 基本运算符
- 每天学习一算法系列(30)(给一个很长的字符串str 还有一个字符集比如{a,b,c} 找出str 里包含{a,b,c}的最短子串。要求O(n).)
- 如何在报表最后一页打东西及系统的一个类似小方法
- 今天才知道C#中还有这么一个运算符"??"
- 今天开始就没有学习任务了,所以打算用.NET写一个系统。
- Jquery:十分钟打造一个类似是Twitter的系统,附源代码
- 数据类型,运算符和表达式02 - 零基础入门学习C语言03
- 用C语言实现一个类似学籍管理系统的 e协 管理系统beta ( 正在完善中...)
- 一个google类似的分页 学习版
- -------实现一个类似迅雷的系统“福雷(FULEI)”
- 数据类型,运算符和表达式03 - 零基础入门学习C语言04
- Struts 1 学习笔记-5-2(编写一个简单的支持I18N的登录系统)
- 数据类型,运算符和表达式02 - 零基础入门学习C语言03
- 推荐一个不错的在线Linux学习平台(免安装系统)