1
類
我已經在我的Rails應用程序擴展Matrix類添加兩個新的方法如下所述:未定義的方法`編譯」:
Two extended classes - one works and the other doesn't
上述方法現在工作得很好。還有些現有方法的正常工作,如
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方法有效時,什麼會導致構建方法無法工作?我是否錯過了一個額外的圖書館或班級?
EDIT 1:我意識到這是因爲我有紅寶石1.8.7當構建方法在1.9.3
所以寫一個答案,並接受以後關閉你的問題。解決方案顯而易見:切換到Ruby 1.9.3(或將新代碼複製到您的庫中,並記住稍後再將其刪除)。 – mliebelt 2012-02-11 12:06:40
我必須不得不等待8個小時 – Zakoff 2012-02-11 12:08:46
但是答案是立即被允許的...... – mliebelt 2012-02-11 12:30:11