what is “$:” in ruby?

前端 未结 3 1801
清酒与你
清酒与你 2021-02-07 06:31

Usually be seen in .gemspec file. eg. i18n.gemspec.

$: << File.expand_path(\'../lib\', __FILE__)
3条回答
  •  感情败类
    2021-02-07 07:14

    $: is the load path and $LOAD_PATH is its alias. When you load/require libraries/files within your ruby application, ruby searches in the directories listed in $: for them. With $: << File.expand_path('../lib', __FILE__) you add a specific directory to the load path.

提交回复
热议问题