* lib/matrix (column): handle negative arguments. cf [ruby-core:23598]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e5af8e940b
commit
90d244aded
@ -309,13 +309,13 @@ class Matrix
|
|||||||
#
|
#
|
||||||
def column(j) # :yield: e
|
def column(j) # :yield: e
|
||||||
if block_given?
|
if block_given?
|
||||||
return self if j >= column_size
|
return self if j >= column_size || j < -column_size
|
||||||
row_size.times do |i|
|
row_size.times do |i|
|
||||||
yield @rows[i][j]
|
yield @rows[i][j]
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
else
|
else
|
||||||
return nil if j >= column_size
|
return nil if j >= column_size || j < -column_size
|
||||||
col = (0 ... row_size).collect {|i|
|
col = (0 ... row_size).collect {|i|
|
||||||
@rows[i][j]
|
@rows[i][j]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user