diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-12 15:45:59 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-12 15:45:59 +0000 |
commit | b28f3e5c4ffb46db1247df8b7aa94a25cf0c3bba () | |
tree | 9176d4ea95572d3740eb06c8e47f771c5701eb45 /lib/prime.rb | |
parent | 5b78e48c318b342c46943a4723f3d556ead7795b (diff) |
* lib/prime.rb: Return sized enumerators.
by Kenichi Kamiya [GH-931] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/prime.rb | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -270,7 +270,7 @@ class Prime # see +Enumerator+#with_index. def with_index(offset = 0) - return enum_for(:with_index, offset) unless block_given? return each_with_index(&proc) if offset == 0 each do |prime| @@ -281,11 +281,15 @@ class Prime # see +Enumerator+#with_object. def with_object(obj) - return enum_for(:with_object, obj) unless block_given? each do |prime| yield prime, obj end end end # An implementation of +PseudoPrimeGenerator+. |