irb(main):002:0> $$
=> 5052
What is the meaning of $$
in Ruby and How/Where to use it?
I do googled it like $$ ruby
, but couldn't get desired result.
irb(main):002:0> $$
=> 5052
What is the meaning of $$
in Ruby and How/Where to use it?
I do googled it like $$ ruby
, but couldn't get desired result.
$$
is the process ID. It's named that way to follow Perl, which in turn followed the Bourne shell; both of them also use $$
in the same way.
This seems like a good reference for stuff like this...has a lot of symboly goodness.
pipe = IO.popen("")
if pipe
STDERR.puts "In parent, child pid is #{pipe.pid}"
else
STDERR.puts "In child, pid is #{$$}"
end
This example shows how the process ID can be used. Process ID is part of 'Execution Environment Variables' (part of predifined variables).