gpt4 book ai didi

ruby - $: in Ruby 是什么意思

转载 作者:数据小太阳 更新时间:2023-10-29 07:41:38 25 4
gpt4 key购买 nike

我正在阅读以下内容 tutorial .

它谈到了将文件包含在 Ruby 文件中,例如 require :

require(string) => true or false

Ruby tries to load the library named string, returning true if successful. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in $:. If the file has the extension ".rb", it is loaded as a source file; if the extension is ".so", ".o", or ".dll", or whatever the default shared library extension is on the current platform, Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tries adding ".rb", ".so", and so on to the name. The name of the loaded feature is added to the array in $:.

我只是想知道Ruby 中的$: 是什么以及$: 是什么意思。

最佳答案

变量$:是执行环境变量之一,是一个数组,用来搜索加载文件的位置。

初始值是通过 -I 命令行选项传递的参数值,后跟安装定义的标准库位置。

参见 Pre-defined variables , $LOAD_PATH 是它的别名。

关于ruby - $: in Ruby 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26799724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com