Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of $$ in Ruby?

Tags:

ruby

irb(main):002:0> $$
=> 5052

What is the meaning of $$ in Ruby and How/Where to use it?

like image 999
YOU Avatar asked Feb 01 '10 13:02

YOU


3 Answers

$$ 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.

like image 193
Chris Jester-Young Avatar answered Nov 08 '22 20:11

Chris Jester-Young


This seems like a good reference for stuff like this...has a lot of symboly goodness.

like image 26
Jason Punyon Avatar answered Nov 08 '22 20:11

Jason Punyon


It's the process ID of the Ruby interpreter. $ is a prefix for global variables, see here for a list.

like image 6
unwind Avatar answered Nov 08 '22 20:11

unwind