Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在查看一些代码示例,我遇到了这一行:
puts "child #$$ accepting..."
哪个输出
>> child 7231 accepting...
看起来 $$ 是 PID,它利用一些简写来表示普通的#{$$}字符串插值语法。不过,我找不到这方面的文档。我很好奇还有什么其他的速记技巧(或者会让我感到困惑)。
#{$$}
文档在哪里?为什么这很特别?
Ruby 允许您在进行字符串插值时省略全局 ( $var)、实例 ( @var) 和类 ( ) 变量的大括号。@@var
$var
@var
@@var