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. java urlEncode 和urlDecode的用法

    前台进行http请求的时候 如果要对中问进行编码,要使用两次编码 String zhName=urlEncode.encode((urlEncode.encode("中文",&qu ...

  2. C#斐波那契数列递归算法

    public static int Foo(int i)        {            if (i < 3)            {                return 1; ...

  3. 学习嵌入式开发板的Android平台体系结构和源码结构

    本文转自迅为论坛资料:http://www.topeetboard.com 推荐学习嵌入式开发板平台:iTOP-4412开发板 下面这张图出自Google官方,展示了Android系统的主要组成部分. ...

  4. codeforces_1075_C. The Tower is Going Home

    http://codeforces.com/contest/1075/problem/C 题意:一个长宽均为1e9的棋盘,n个垂直障碍在x列无限长,m个水平障碍在第y行从第x1列到x2列.可以水平和垂 ...

  5. Less用法注意事项

    (1)引入顺序 引入你的 .less 样式文件的时候要设置 rel 属性值为 “stylesheet/less”: <link rel="stylesheet/less" t ...

  6. Danfoss Motor - Automotive Motor: What Sensors Are There?

    The   Danfoss Motor     states that the motor sensor control system is the heart of the entire autom ...

  7. Java的类加载

    虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的Java类型,这就是Java虚拟机的类加载机制 ----类加载的大致过程 类的加载的过 ...

  8. nohup 忽略所有挂断信号

    1.nohup 用途:不挂断地运行命令. 语法:nohup Command [ Arg … ] [ & ] 无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup ...

  9. 8.url路由

    1.单一路由对应 url(r'^index/$', views.index), 这里要注意的是,/$ 表示只有只/结尾的才有效,如果把$符号去掉的话,只要是以index/开头都会匹配到这个url. 2 ...

  10. SQL-如何使用 MongoDB和PyMongo。

    先决条件 在开始之前,请确保已经安装了 PyMongo 发行版. 在 Python shell 中,下面的代码应该在不引发异常的情况下运行: >>> import pymongo 假 ...