Ruby预定义全局变量

Ruby预定义全局变量
2011-05-09 14:59

Ruby's predefined (built-in) variables affect the behavior of the entire program, so their use in libraries isn't recommended. The values in most predefined variables can be accessed by alternative means.

$!

The last exception object raised. The exception object can also be accessed using => in rescue clause.

$@

The stack backtrace for the last exception raised. The stack backtrace information can retrieved by Exception#backtrace method of the last exception.

$/

The input record separator (newline by default). gets, readline, etc., take their input record separator as optional argument.

$\

The output record separator (nil by default).

$,

The output separator between the arguments to print and Array#join (nil by default). You can specify separator explicitly to Array#join.

$;

The default separator for split (nil by default). You can specify separator explicitly for String#split.

$.

The number of the last line read from the current input file. Equivalent to ARGF.lineno.

$<

Synonym for ARGF.

$>

Synonym for $defout.

$0

The name of the current Ruby program being executed.

$$

The process.pid of the current Ruby program being executed.

$?

The exit status of the last process terminated.

$:

Synonym for $LOAD_PATH.

$DEBUG

True if the -d or --debug command-line option is specified.

$defout

The destination output for print and printf ($stdout by default).

$F

The variable that receives the output from split when -a is specified. This variable is set if the -a command-line option is specified along with the -p or -n option.

$FILENAME

The name of the file currently being read from ARGF. Equivalent to ARGF.filename.

$LOAD_PATH

An array holding the directories to be searched when loading files with the load and require methods.

$SAFE

The security level. See 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值