zoukankan      html  css  js  c++  java
  • swift基础

    基础语法

    if-else

    let age =4

    for(区间)

    let rang = ...10
    rang.contains(11) //false
    rang.contains(6) ..ture

    带间隔的区间值

    for tickMark in stride(form: 4, through: 11, by: 2){
    printf(tickMark)
    } // 4, 6, 8, 10

    switch

    switch num {
    case 1:
    printf(num)
    fallthrough
    case 2: printf(num)
    default:
    break
    }
    case, default后面至少要有一条语句
    //##where
    //var number = [10, -10, -20, 20, 30, -30]
    //var sum
    //for num in number where num >0 {
    // sum += num
    //}
    print(sum) //60

    标签语句

    outer: for i in 1...4 {
    for k in 1...4{
    if k == 3 {
    continue outer
    }
    if i == 3 {
    break outer
    }
    print("i =", i, "k =", k)
    }
    }
    /i = 1 k = 1
    i = 1 k = 2
    i = 2 k = 1
    i = 2 k = 2
    /

    可变参数

    func sum(_ numbers: Int...) ->Int{
    var totaol
    }

    嵌套函数

    //func forward(_ forward: Bool) -> (Int) -> Int {
    // func next(_ input: Int) -> Int {
    // return input + 1
    // }
    // func previous(_ input: Int) -> Int {
    // return input - 1
    // }
    // return forward?next:previous
    //}
    //
    //let m = forward(10)(3)
    //forward(true)(3) //4
    //forward(false)(3) //2

  • 相关阅读:
    MySQL--mysqldump的权限说明
    JS--switch 语句
    psutil官方文档
    mysql 性能分析套件
    mysql 在启动时配置文件的查找方式
    mysql中的意向锁IS,IX
    mysql innodb_double_write特性
    mysql sql_mode 之 NO_ENGINE_SUBSTITUTION
    编译安装hph
    pip list 和 pip freeze
  • 原文地址:https://www.cnblogs.com/wwjwb/p/13467076.html
Copyright © 2011-2022 走看看