Skip to content

Commit b109d90

Browse files
committed
LockFreeLinkedSet: always return self in <<
1 parent f55c03d commit b109d90

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/concurrent/edge/lock_free_linked_set.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def add(item)
5555
#
5656
# @return [Oject] the set on which the :<< method was invoked
5757
def <<(item)
58-
self if add item
58+
add item
59+
self
5960
end
6061

6162
# @!macro [attach] lock_free_linked_list_method_contains

spec/concurrent/edge/lock_free_linked_set_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
it 'appends to the linked set and returns self' do
4545
expect(subject << 'test string1').to be_a described_class
4646
end
47+
48+
it 'returns self regardless of whether it was logically added' do
49+
subject << 'test string'
50+
expect(subject << 'test string').to be_a described_class
51+
end
4752
end
4853

4954
describe '#contains?' do

0 commit comments

Comments
 (0)