當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Swift BooleanLiteralType用法及代碼示例

類型別名

BooleanLiteralType

otherwise-unconstrained 布爾文字的默認類型。

聲明

typealias BooleanLiteralType = Bool

詳述

當您使用布爾文字 truefalse 之一創建常量或變量時,生成的類型由 BooleanLiteralType 別名確定。例如:


let isBool = true
print("isBool is a '\(type(of: isBool))'")
// Prints "isBool is a 'Bool'"

BooleanLiteralType 別名的類型必須符合ExpressibleByBooleanLiteral 協議。

可用版本

iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+

相關用法


注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 BooleanLiteralType。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。