Project

General

Profile

Feature #11007 » prime.diff

ciel (T Yamada), 03/27/2015 03:10 PM

View differences:

lib/prime.rb
end
# see +Enumerator+#with_index.
alias with_index each_with_index
def with_index(offset = 0, &blk)
return enum_for(:with_index) unless block_given?
# if offset == 0, use each_with_index, which is faster because of C implementation.
return each_with_index(&blk) if offset == 0
each do |prime|
yield prime, offset
offset += 1
end
end
# see +Enumerator+#with_object.
def with_object(obj)
test/test_prime.rb
assert_equal PRIMES[i], p
last = i
end
last = 5-1
enum.with_index(5) do |p,i|
break if i >= 100+5
assert_equal last+1, i
assert_equal PRIMES[i-5], p
last = i
end
end
def test_default_instance_does_not_have_compatibility_methods
(1-1/2)