操作符
+(_:)
返回给定的数字不变。
声明
static func + (x: Self) -> Self
返回值
给定的参数没有任何变化。
详述
在使用一元减号运算符时,您可以使用一元加号运算符 (+
) 在代码中为正数提供对称性。
let x = -21
let y = +21
// x == -21
// y == 21
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相关用法
- Swift AdditiveArithmetic +(_:_:)用法及代码示例
- Swift AdditiveArithmetic -(_:_:)用法及代码示例
- Swift AdditiveArithmetic用法及代码示例
- Swift Array enumerated()用法及代码示例
- Swift AnySequence elementsEqual(_:)用法及代码示例
- Swift ArraySlice starts(with:)用法及代码示例
- Swift ArraySlice reduce(_:_:)用法及代码示例
- Swift Array allSatisfy(_:)用法及代码示例
- Swift AnyCollection min()用法及代码示例
- Swift AsyncThrowingFlatMapSequence min()用法及代码示例
- Swift AnyBidirectionalCollection elementsEqual(_:)用法及代码示例
- Swift AnyRandomAccessCollection randomElement(using:)用法及代码示例
- Swift AsyncPrefixWhileSequence reduce(_:_:)用法及代码示例
- Swift AsyncThrowingMapSequence reduce(_:_:)用法及代码示例
- Swift AnyBidirectionalCollection lexicographicallyPrecedes(_:)用法及代码示例
- Swift AnyHashable ==(_:_:)用法及代码示例
- Swift AsyncDropWhileSequence allSatisfy(_:)用法及代码示例
- Swift AsyncSequence dropFirst(_:)用法及代码示例
- Swift AnyBidirectionalCollection split(separator:maxSplits:omittingEmptySubsequences:)用法及代码示例
- Swift AnyRandomAccessCollection first(where:)用法及代码示例
- Swift AnyBidirectionalCollection sorted()用法及代码示例
- Swift AsyncDropFirstSequence filter(_:)用法及代码示例
- Swift AsyncSequence reduce(_:_:)用法及代码示例
- Swift AsyncFlatMapSequence min()用法及代码示例
- Swift AsyncThrowingPrefixWhileSequence drop(while:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 AdditiveArithmetic +(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。