Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/fromarray.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

module Stream
# A stream implemented based on an Array.
# This class is immutable and thread-safe.
# Author:: Mihai Andronache (amihaiemil@gmail.com)
class FromArray
def initialize(array)
Expand All @@ -38,8 +39,7 @@ def skip(count)
@array.each_with_index do |val, index|
skipped.push(val) unless index + 1 <= count
end
@array = skipped
self
FromArray.new(skipped)
end

# Collect the stream's data into an array and return it.
Expand Down
4 changes: 2 additions & 2 deletions test/fromarray_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_skip_argument_error_count_negative
def test_skip_returns_self
stream = FromArray.new([1, 2, 3])
assert(
stream.skip(1).equal?(stream),
'Method skip should return the modified stream'
!stream.skip(1).equal?(stream),
'Method skip should return a new instance of the modified stream'
)
end

Expand Down