зеркало из https://github.com/github/ruby.git
* lib/matrix.rb (each2,collect2,map2): Fix enumerator [ruby-core:27225]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
93278f2387
Коммит
fad1e8c761
|
@ -1,3 +1,8 @@
|
|||
Sat Dec 19 11:06:48 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/matrix.rb (each2,collect2,map2): Fix enumerator
|
||||
[ruby-core:27225]
|
||||
|
||||
Sat Dec 19 09:58:05 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_eval.c (check_funcall): reset method_missing_reason before
|
||||
|
|
|
@ -1147,7 +1147,7 @@ class Vector
|
|||
#
|
||||
def each2(v) # :yield: e1, e2
|
||||
Vector.Raise ErrDimensionMismatch if size != v.size
|
||||
return to_enum(:each2) unless block_given?
|
||||
return to_enum(:each2, v) unless block_given?
|
||||
size.times do |i|
|
||||
yield @elements[i], v[i]
|
||||
end
|
||||
|
@ -1159,7 +1159,7 @@ class Vector
|
|||
#
|
||||
def collect2(v) # :yield: e1, e2
|
||||
Vector.Raise ErrDimensionMismatch if size != v.size
|
||||
return to_enum(:collect2) unless block_given?
|
||||
return to_enum(:collect2, v) unless block_given?
|
||||
(0 ... size).collect do |i|
|
||||
yield @elements[i], v[i]
|
||||
end
|
||||
|
@ -1290,7 +1290,7 @@ class Vector
|
|||
# Like Vector#collect2, but returns a Vector instead of an Array.
|
||||
#
|
||||
def map2(v, &block) # :yield: e1, e2
|
||||
return to_enum(:map2) unless block_given?
|
||||
return to_enum(:map2, v) unless block_given?
|
||||
els = collect2(v, &block)
|
||||
Vector.elements(els, false)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче