* lib/matrix.rb (Vector#each): make Vector enumerable.
[ruby-core:28405] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
006a8ba77f
commit
2cfb894d2a
@ -1,3 +1,8 @@
|
|||||||
|
Wed Mar 3 16:14:24 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/matrix.rb (Vector#each): make Vector enumerable.
|
||||||
|
[ruby-core:28405]
|
||||||
|
|
||||||
Wed Mar 3 14:28:23 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Mar 3 14:28:23 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_select_bang): select! removes all elements for
|
* array.c (rb_ary_select_bang): select! removes all elements for
|
||||||
|
@ -1081,6 +1081,7 @@ end
|
|||||||
#
|
#
|
||||||
class Vector
|
class Vector
|
||||||
include ExceptionForMatrix
|
include ExceptionForMatrix
|
||||||
|
include Enumerable
|
||||||
|
|
||||||
#INSTANCE CREATION
|
#INSTANCE CREATION
|
||||||
|
|
||||||
@ -1140,6 +1141,16 @@ class Vector
|
|||||||
# ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
# ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
#
|
||||||
|
# Iterate over the elements of this vector
|
||||||
|
#
|
||||||
|
def each
|
||||||
|
return to_enum(:each) unless block_given?
|
||||||
|
@elements.each do |i|
|
||||||
|
yield i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Iterate over the elements of this vector and +v+ in conjunction.
|
# Iterate over the elements of this vector and +v+ in conjunction.
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user