Ruby 中以 $ 为前缀的神奇变量是什么? [英] What are the magic $-prefixed variables in Ruby?

查看:40
本文介绍了Ruby 中以 $ 为前缀的神奇变量是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过像这样在 Ruby 中使用的魔法变量.$_ $' $0

I've seen magic variables like this used in Ruby. $_ $' $0

是否有完整的参考来说明它们的含义以及它们的设置方式?

Is there a complete reference for what all of them mean and how they are set?

推荐答案

它们的名字是全局变量.有几个不同的参考.

Their name is global variables. There are several different references.

您可以通过调用方法Kernel#global_variables

puts global_variables

Ruby 还包含一个名为English.rb 的文件" 在标准库中,它提供了几个全局变量的深入解释.

Ruby also includes a file called "English.rb" in the standard library which provides an in-depth explanation of several global variables.

此外,还有(存档版本)Cryptic Ruby 全局变量及其含义".

Also, there's (an archived version of) "Cryptic Ruby Global Variables and Their Meanings".

最后,Ruby Programming wikibook 有一个预定义变量"参考.

Finally, the Ruby Programming wikibook has a "Predefined Variables" reference.

这篇关于Ruby 中以 $ 为前缀的神奇变量是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆