Project

General

Profile

Bug #2495

Matrix: Vector#each2 should check its argument

Added by marcandre (Marc-Andre Lafortune) over 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.2dev (2009-12-19 trunk 26121) [x86_64-darwin10.2.0]
Backport:
[ruby-core:27223]

Description

=begin
$ rubydev -r matrix -e 'p Vector[*1..4].each2(nil){|x, y| p "#{x}, #{y}"}'
/usr/local/rubydev/lib/ruby/1.9.1/matrix.rb:1149:in each2': undefined methodsize' for nil:NilClass (NoMethodError)

$ rubydev -r matrix -e 'p Vector[*1..4].each2(42){|x, y| p "#{x}, #{y}"}'
/usr/local/rubydev/lib/ruby/1.9.1/matrix.rb:1149:in each2': Vector dimension mismatch (ExceptionForMatrix::ErrDimensionMismatch)
from -e:1:in
'

$ rubydev -r matrix -e 'p Vector[*1..8].each2(42){|x, y| p "#{x}, #{y}"}'
"1, 0"
"2, 1"
"3, 0"
"4, 1"
"5, 0"
"6, 1"
"7, 0"
"8, 0"

(or vice versa, if on a 32 bit platform)
=end

Also available in: Atom PDF