RangeReplaceableCollection
extension RangeReplaceableCollection
extension RangeReplaceableCollection where Self: BidirectionalCollection
-
Replace element at given
index
with the givenelement
.Declaration
Swift
@discardableResult public mutating func replaceElement(at index: Index, with element: Element) -> Element
-
Immutable version of
replaceElement(at:with:)
Declaration
Swift
public func replacingElement(at index: Index, with element: Element) -> Self
-
Replace first element in Array with a new element.
Declaration
Swift
@discardableResult public mutating func replaceFirst(with element: Element) -> Element
-
Declaration
Swift
public func inserting(_ element: Element, at index: Index) -> Self
Return Value
A new
Array
with the givenelement
inserted at the givenindex
, if possible.
-
Replace the last element in
Self
with the givenelement
.Declaration
Swift
@discardableResult public mutating func replaceLast(with element: Element) -> Element