Ruby的一些常用全局变量

$!

latesterror message

$@

locationof error

$_

stringlast read by gets

$.

linenumber last read by interpreter

$&

stringlast matched by regexp

$~

thelast regexp match, as an array of subexpressions

$n

thenth subexpression in the last match (same as $~[n])

$=

case-insensitivityflag

$/

inputrecord separator

$\

outputrecord separator

$0

thename of the ruby script file

$thecommand line arguments

$$

interpreter’sprocess ID

$?

exit status of last executed child process

posted @ 2013-08-16 16:19  chenpassion  阅读(334)  评论(0编辑  收藏  举报