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

 

转载于:https://www.cnblogs.com/fantasy3588/p/5064993.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值