Swapping
-
If the given predicate is
true, the givenaandbvalues are swapped in aninoutfasion, andtrueis returned. Otherwise, noswaptakes place, andfalseis 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
predicateistrue, a tuple of(b, a, true)Otherwise,(a, b, false)
View on GitHub
Install in Dash
Swapping Reference