Why does ruby โ€‹โ€‹allow me to use # $$ to print the PID in a string?

I watched a few code examples and I came across this line:

puts "child #$$ accepting..." 

which outputs

 >> child 7231 accepting... 

$$ seems to be a PID, and it uses some abbreviation for the usual syntax for interpolating strings #{$$} . However, I can not find the documentation. I'm curious what other short tricks are available (or confuse me).

Where are the documents? Why is this special?

+7
source share
1 answer

Ruby allows you to skip bindings for global variables ( $var ), instance ( @var ), and class ( @@var ) when performing string interpolation.

+5
source

All Articles