zoukankan      html  css  js  c++  java
  • Swift 命名规则

    Swift可以使用几乎任何字符作为常量和变量名,包括Unicode,但是不能包含数字符号、箭头、无效的Unicode、横线-、制表符、且不能以数字开头。

    var π = 3.14

     

    var 新空气软件 = "开发软件"

     

    let 你好 = "你好世界"

     

    整形的表现形式

    二进制:前缀0b

    八进制:前缀0o

    十六进制:前缀0x

    let decimalInteger = 14

    let binaryInteger = 0b10001

    let octalInterger = 0o21

    let hexadecimlInteger = 0x11

     

    let minValue = UInt8.min

    let maxValue = UInt8.max

    UInt8 是一个结构体struct

    {

    public struct UInt8 : UnsignedIntegerType, Comparable, Equatable {

        public var value: Builtin.Int8

        /// A type that can represent the number of steps between pairs of

        /// values.

        public typealias Distance = Int

        /// Create an instance initialized to zero.

        public init()

        /// Create an instance initialized to `value`.

        public init(_ value: UInt8)

        public init(_builtinIntegerLiteral value: Builtin.Int2048)

        /// Create an instance initialized to `value`.

        public init(integerLiteral value: UInt8)

        public static var max: UInt8 { get }

        public static var min: UInt8 { get }


    }

     

    //类型别名

     

    typealias NSInteger = Int

     

    var value: NSInteger = 45

     

    value = 12

     

    print(value)

     

    // 布尔类型

    var tigerIsAnimal: Bool = true

     

    1
  • 相关阅读:
    Webpack2 那些路径
    Nginx alias 和 root配置
    前端代码监控
    Class和构造函数的异同
    Async和await
    如何在git中删除指定的文件和目录
    微信小程序数字转化条形码和二维码
    vue 结合swiper插件实现广告公告上下滚动的效果
    vue2.0 结合better-scroll 实现下拉加载
    FormData对象提交表单和form提交表单
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5064993.html
Copyright © 2011-2022 走看看