Project

General

Profile

Actions

Bug #2495

closed

Matrix: Vector#each2 should check its argument

Added by marcandre (Marc-Andre Lafortune) almost 15 years ago. Updated over 13 years ago.

Status:
Closed
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 method size' 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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0