gpt4 book ai didi

ios - Swift 中无法解释的关键字 : left, 无,对,类型。他们在做什么?

转载 作者:搜寻专家 更新时间:2023-10-31 22:00:23 24 4
gpt4 key购买 nike

我一直在阅读 Apple 的 Swift 编程语言书籍(针对 Swift 2.0 更新的版本),我发现了一些非常奇怪的东西。在 Language Reference > Lexical Stricture > Keywords and Punctuation(link here - 但你需要向下滚动一点)有一个语言列表关键字。其中一些在任何地方都没有解释。

Keywords reserved in particular contexts: associativity, convenience, dynamic, didSet, final, get, infix, inout, lazy, left, mutating, none, nonmutating, optional, override, postfix, precedence, prefix, Protocol, required, right, set, Type, unowned, weak, and willSet. Outside the context in which they appear in the grammar, they can be used as identifiers.

您知道它们的作用/含义或在哪里可以找到适用信息吗?

最佳答案

leftrightnone 用于指定自定义运算符的结合性:

The associativity of an operator specifies how a sequence of operators with the same precedence level are grouped together in the absence of grouping parentheses. You specify the associativity of an operator by writing the context-sensitive keyword associativity followed by the associativity, which is one of the context-sensitive keywords left, right, or none.

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/swift/grammar/associativity

Type 与元类型一起使用:

A metatype type refers to the type of any type, including class types, structure types, enumeration types, and protocol types.

The metatype of a class, structure, or enumeration type is the name of that type followed by .Type.

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/swift/grammar/metatype-type

关于ios - Swift 中无法解释的关键字 : left, 无,对,类型。他们在做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31985671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com