Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 1461e5f

Browse files
dmcrodriguesandersio
authored andcommitted
subscript(position:) should replace and not append a new element
1 parent acae769 commit 1461e5f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/ReactiveArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extension ReactiveArray: MutableCollection {
6868
return elements[position]
6969
}
7070
set {
71-
replaceSubrange(position..<position, with: CollectionOfOne(newValue))
71+
replaceSubrange(position..<index(after: position), with: CollectionOfOne(newValue))
7272
}
7373
}
7474

Tests/ReactiveArrayTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ReactiveArrayTests: XCTestCase {
9292
XCTAssertEqual(array[2], 3)
9393
}
9494

95-
func test_subscripting_insert_at_tail() {
95+
func test_subscripting_replace_at_head() {
9696

9797
var changeset: Changeset<Int>? = nil
9898

0 commit comments

Comments
 (0)