从Ruby中的实例变量创建Matrix

时间:2017-12-16 16:17:35

标签: ruby-on-rails ruby matrix

以下命令

@offers = Matrix[]
allotment_matrix = Matrix[@proposal, @facility, @price.to_i, @keywords]
@offers = @offers.vstack(allotment_matrix)

将数据生成为34, 40, #<BigDecimal:7fb1339a5420,'0.38E3',9(18)>, " Near train station“`,然后处理错误:

TypeError: can't convert Fixnum into an Array (undefined method `to_ary' for 32:Fixnum

documentation

x = Matrix[[1, 2], [3, 4]]
y = Matrix[[5, 6], [7, 8]]
Matrix.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]

我无法看到如何创建矩阵

0 个答案:

没有答案