1 字符和字符串初步 

var c :Character = "a"

2 构造字符串 

let str1 = "hello"
let str2 = " world"
let str = str1 + str2
print(str)//hello world
print("hello\(str2)")//hello world

数学运算符 

(+, -, *, /, %)

赋值运算符 

= , +=, -+, *=, /=, %=

关系运算符 

>, <, >=, <=, ==, !=, ?:

逻辑运算符 

1. ! 逻辑非!a a不为0时!a表达式为ture a为0时,表达式为false
2. && 逻辑与a&&ba和b全为ture 表达式才为ture
3. || 逻辑或a||ba和b最少有一个为ture 表达式为ture
注意:逻辑运算符对象必须是布尔值类型。

区间运算符

1.闭区间运算符:a...b

for icount in ... {
print(icount)//从1遍历到10(包括10)
}

2.半闭区间运算符:a..<b

for icount in ..< {
print(icount)//从1遍历到10(不包括10)
}

学习swift从青铜到王者之字符串和运算符02的更多相关文章

  1. 学习swift从青铜到王者之swift属性09

    1.结构体常量和类常量的存储属性 let p1 = Person1() //p1.age = 88 不允许修改 //p11.name = "yhx1" 不允许修改 var p11 ...

  2. 学习swift从青铜到王者之swift闭包06

    语法表达式 一般形式:{ (parameters) -> returnType in statements } 这里的参数(parameters),可以是in-out(输入输出参数),但不能设定 ...

  3. 学习swift从青铜到王者之swift结构体和类08

    定义 // 定义类 class StudentC{ } // 定义结构体 struct StudentS{ } 定义存储属性 // 定义类 class StudentC{ var name:Strin ...

  4. 学习swift从青铜到王者之swift枚举07

    空枚举 //空枚举 enum SomeEnumeration { // enumeration definition goes here } 枚举基本类型 //枚举基本类型 enum CompassP ...

  5. 学习swift从青铜到王者之Swift语言函数05

    1.定义一个函数以及调用 //一,定义一个无参无返回值函数 func fun1(){ print("this is first function") } fun1() 2.定义一个 ...

  6. 学习swift从青铜到王者之Swift控制语句04

    1 if语句基本用法 if boolean_expression { /* 如果布尔表达式为真将执行的语句 */ } 如果布尔表达式为 true,则 if 语句内的代码块将被执行.如果布尔表达式为 f ...

  7. 学习swift从青铜到王者之Swift集合数据类型03

    1 数组的定义 var array1 = [,,,] var array2: Array = [,,,] var array3: Array<Int> = [,,,] var array4 ...

  8. 学习swift从青铜到王者之swift基础部分01

    1.1 变量和常量 var 变量名称 = 值(var可以修改) let 常量名称 = 值(let不可以修改) 1.2 基本数据类型 整数类型和小数类型 两种基本数据类型不可以进行隐式转换 var in ...

  9. 学习Android从青铜到王者之第一天

    1.Android四层架构 一.Linux Kernel 二.Libraries和Android Runtime 三.Application Framework 四.Applications 一.Li ...

随机推荐

  1. Objective -C Object initialization 对象初始化

    Objective -C Object initialization 对象初始化 1.1 Allocating Objects  分配对象 Allocation is the process by w ...

  2. spring mvc介绍只试图解析(转载)

    转载路径 http://haohaoxuexi.iteye.com/blog/1770554 SpringMVC视图解析器 前言 在前一篇博客中讲了SpringMVC的Controller控制器,在这 ...

  3. 迅为iTOP-4418/6818开发板MiniLinux下的GPS使用手册

    平台:iTOP-4418/6818开发板 系统:MiniLinux 在 Mini Linux 系统环境下 iTOP-4418 和 6818 的 GPS 实验调试步骤.给用户提供了“iTOP-4418- ...

  4. 使用Let's Encrypt 生成免费的ssl证书的详细过程

    参考连接:https://github.com/diafygi/acme-tiny 中文:https://hacpai.com/article/1487899289204 目前我了解可以生成免费证书的 ...

  5. 所有的工作目录 都要svn_开头,并且要进行svn同步,你能保证你不删除,你保证不了非你!

    所有的工作目录 都要svn_开头,并且要进行svn同步,你能保证你不删除,你保证不了非你! 血的代价啊~

  6. 【HTML5】可以省略标记的元素

  7. opencv读图片错误,已解决

    could not loag image... terminate called after throwing an instance of 'cv::Exception' what(): OpenC ...

  8. vue 轮播插件使用

    <template> <div> <Swiper ref="swiper" v-if="list.length > 0" : ...

  9. 启发式合并CSU - 1811

    F - Tree Intersection CSU - 1811 Bobo has a tree with n vertices numbered by 1,2,…,n and (n-1) edges ...

  10. 笔试算法题(26):顺时针打印矩阵 & 求数组中数对差的最大值

    出题: 输入一个数字矩阵,要求从外向里顺时针打印每一个数字: 分析: 从外向里打印矩阵有多重方法实现,但最重要的是构建合适的状态机,这样才能控制多重不同的操作: 注意有四种打印模式(左右,上下,右左, ...