ruby - Ruby 中的 require_relative 和 require 有什么区别?

标签 ruby require

Ruby 中的 require_relativerequire 有什么区别?

最佳答案

看看docs :

require_relative complements the builtin method require by allowing you to load a file that is relative to the file containing the require_relative statement.

For example, if you have unit test classes in the "test" directory, and data for them under the test "test/data" directory, then you might use a line like this in a test case:

require_relative "data/customer_data_1"

关于ruby - Ruby 中的 require_relative 和 require 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3672586/

相关文章:

Ruby 反序列化 YAML

javascript - Ruby On Rails Ajax 提交 提交两次

ruby - 有没有办法在 RUBY 中进行 T 检验?

php - Laravel - 验证 - 如果字段为空则需要

javascript - 使用 Express 访问 Node.js 中的模型

PHP:包含在包含文件中

ruby - DRY 与重复特征规范

ruby - 为什么哈希递归比 lambda 递归快?

module - 所需脚本中的代码 "local a = (...);"是什么意思?

php - 如何获取包含 php 文件的页面