如何在 IRB 中使用 Ruby Vector 类

shi*_*hin 1 ruby vector

我在 IRB 中尝试了Ruby cross_product 。但它给出了一个错误。

irb(main):055:0> Vector[1, 0, 0].cross_product Vector[0, 1, 0]
NameError: uninitialized constant Vector
Run Code Online (Sandbox Code Playgroud)

如何在 IRB 中测试 Vector 类?

rom*_*man 6

你只需要需要“矩阵”库,只需

require 'matrix'
Run Code Online (Sandbox Code Playgroud)

在 IRB 会议上。