diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 08:19:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 08:19:14 +0000 |
commit | 9f1fb0a17febc59356d58cef5e98db61a3c03550 (patch) | |
tree | 14c3bf6cd585b859d030ec8d41e6b6e16b0e01e7 /lib | |
parent | ec336fb40e4df0c8615e584fbefb5e9e572cb9ec (diff) | |
download | ruby-9f1fb0a17febc59356d58cef5e98db61a3c03550.tar.gz |
proc.c: proc without block
* proc.c (proc_new): promoted lambda/proc/Proc.new with no block
in a method called with a block to a warning/error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/matrix.rb | 3 | ||||
-rw-r--r-- | lib/prime.rb | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb index 7f338bb07e..34602f5c40 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -514,12 +514,11 @@ class Matrix # # => prints the numbers 1 to 4 # Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3] # - def each(which = :all) # :yield: e + def each(which = :all, &block) # :yield: e return to_enum :each, which unless block_given? last = column_count - 1 case which when :all - block = Proc.new @rows.each do |row| row.each(&block) end diff --git a/lib/prime.rb b/lib/prime.rb index 9f6db448be..3aa20f8def 100644 --- a/lib/prime.rb +++ b/lib/prime.rb @@ -283,9 +283,9 @@ class Prime end # see +Enumerator+#with_index. - def with_index(offset = 0) - return enum_for(:with_index, offset) { Float::INFINITY } unless block_given? - return each_with_index(&proc) if offset == 0 + def with_index(offset = 0, &block) + return enum_for(:with_index, offset) { Float::INFINITY } unless block + return each_with_index(&block) if offset == 0 each do |prime| yield prime, offset |