I discovered a special global variable in Ruby. It's $$ and it's always a number. But what does it mean? Even in the documentation I can't find anything.
It's a preset variable that represents the current process' ID. It's documented in http://ruby-doc.org/stdlib-2.3.1/libdoc/English/rdoc/English.html.
Process.pid is an alternate, or use:
require 'English'
my_pid = $PROCESS_ID
In general, the short-cut globals are discouraged from use because they're like magical incantations or visual noise unless you know what they are.
That's one of the pre-defined Ruby global variables.
All globals are prefixed with $, and in this case $$ represents the current process ID. This was inherited from Perl.
Some things aren't very easy to search for, and $$ is one of them, so it's understandable why you couldn't find it easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With