Swapping
-
If the given predicate is
true
, the givena
andb
values are swapped in aninout
fasion, andtrue
is returned. Otherwise, noswap
takes place, andfalse
is returned.Declaration
Swift
@discardableResult public func swap<T>(_ a: inout T, _ b: inout T, if predicate: () -> Bool) -> Bool
-
Undocumented
Declaration
Swift
public func swapped<T, U>(_ a: T, _ b: U) -> (U, T)
-
Declaration
Swift
public func swapped<T>(_ a: T, _ b: T, if predicate: () -> Bool) -> (T, T, Bool)
Return Value
If the given
predicate
istrue
, a tuple of(b, a, true)
Otherwise,(a, b, false)