我正在学习如何在ruby中使用数据结构。
我在github上找到了这个库:https://github.com/kanwei/algorithms/tree/master。
我在本地创建了一个word_count.rb文件。 我想在我的ruby类文件中本地使用我提到的库。
如何在类文件中使用此项目?
答案 0 :(得分:2)
它作为宝石发布(只是你找到的页面没有记录这个事实):https://rubygems.org/gems/algorithms
因此,如果项目中有Gemfile
,请添加以下行:
gem "algorithms", "~> 0.6.1"
否则,请运行以下命令:
gem install algorithms
并像使用任何其他宝石一样使用它,
require 'algorithms'
在你的一个源文件中。
答案 1 :(得分:1)
require 'algorithms' include Containers