zoukankan      html  css  js  c++  java
  • Swift学习笔记

    常量 :let product_constant = "iphone6"

    变量 :var product_var = "ipad" //不需要声明变量类型,会根据右侧的值推导左侧变量的类型

    可以多个变量定义在一起:var x1 = 30, x2 = "abc"

    可以精确指定变量的类型: var x1:Int = 27 //指定x1为INT型

    println(x1)//输出打印单个变量

    println("x1=(x1), x2=(x2)")//输出打印多个变量

    初始化字符串

    var emptyString1 = ""

    var emptyString2 = String()

    var string3 = "abc"

    var string4 = String("abc")

    比较字符串

    if(string3 == string4){

    }

    连接字符串

    let str1 = "hello"

    let str2 = "world"

    var str3 = str1 + str2 //str3就等于"hello world"

    str1 += str2 //str1就等于"hello world"

    字符串大小写转换

    let lowerStr = "abc"

    let upperStr = lowerStr.uppercaseString//小写变大写

    let lowerStr2 = upperStr.lowercaseString//大写变小写

    元组常量和变量

    let product1 = (20,"iphone6",5888)

    let product_name = "iphone4s"

    var product2 = (10,"(product_name)",3888)

    println(product1)//(20,iphone6,5888)

    println(product2)//(10,iphone4s,3888)

  • 相关阅读:
    Spring配置文件中别名的使用
    Spring IOC容器创建对象的方式
    sass安装及使用
    word转html 压缩图片网站
    Yarn 和 Npm 命令行切换 摘录
    react生命周期
    event事件
    Flex 布局
    YYYY-mm-dd HH:MM:SS 时间格式
    页面按钮埋点+跟踪location.search
  • 原文地址:https://www.cnblogs.com/tt_mc/p/3840515.html
Copyright © 2011-2022 走看看