From: Jason Lillywhite Date: 2008-06-12T04:37:23+09:00 Subject: array collect - nil can't be coerced into Float (TypeError) I have this simple program that has a problem that I just can't find a solution to: *********** class MyArray def count a = [50.1,52.0,55.0,60.0] b = [0.24,0.1,0.29,0.9] i = 0 c = [] while i <= 4 do puts c = b.collect {|x| x * a[i]} i += 1 end end end number = MyArray.new number.count ********* I want each element of array 'b' to be multiplied by each element of 'a' and return a vector, 'c' with 16 rows. this code works, but I get an error that says: ArrayInsert.rb:9:in `*': nil can't be coerced into Float (TypeError) from ArrayInsert.rb:9:in `count' from ArrayInsert.rb:9:in `collect' from ArrayInsert.rb:9:in `count' from ArrayInsert.rb:17 I don't understand where 'nil' is coming from. Can someone help me with this one? Thank you. -- Posted via http://www.ruby-forum.com/.