未定义的方法“构建”对于矩阵:类
我在 Rails 应用程序中扩展了 Matrix 类,添加了两个新方法,如下所述:
上述方法现在可以正常工作。另外,一些现有方法可以正常工作,例如
Matrix.column_vector([4,5,6])
Matrix.columns([[25, 93], [-1, 66]])
但
Matrix.build(2, 4) {|row, col| col - row }
Matrix.build(3) { rand }
不起作用并给出错误
undefined method `build' for Matrix:Class
这些方法都在此页面中定义:
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/matrix/rdoc/Matrix.html#method-c-build
可能导致构建方法不起作用的原因,其他 Matrix 方法何时起作用?我错过了额外的图书馆或课程吗?
编辑1:我意识到这是因为当构建方法在 1.9.3 中定义时我有 ruby 1.8.7
I have extended the Matrix class in my rails app to add two new methods as described here:
Two extended classes - one works and the other doesn't
The above methods now work fine. Also some of the existing methods work fine such as
Matrix.column_vector([4,5,6])
Matrix.columns([[25, 93], [-1, 66]])
but
Matrix.build(2, 4) {|row, col| col - row }
Matrix.build(3) { rand }
do not work and give the error
undefined method `build' for Matrix:Class
The methods are all defined in this page here:
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/matrix/rdoc/Matrix.html#method-c-build
What could be causing the build method to not work, when other Matrix methods do work? Am I missing an extra library or class?
EDIT 1: I realised it is because I have ruby 1.8.7 when the build method is defined in 1.9.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到这是因为我有 ruby 1.8.7,而构建方法是在 1.9.3 中定义的
I realised it is because I have ruby 1.8.7 when the build method is defined in 1.9.3