In ruby what does “$$” mean?

前端 未结 3 1241
一个人的身影
一个人的身影 2021-01-27 23:39

In my rails console:

$$
#=> 12680

in IRB in other tab:

$$
#=> 15550

What does $$ stands fo

相关标签:
3条回答
  • 2021-01-28 00:23

    My google-fu shows me that $$ is the process number of the Ruby running the script.

    0 讨论(0)
  • 2021-01-28 00:31

    From "Ruby Programming/Syntax/Variables and Constants":

    $$ - $PROCESS_ID, $PID or Process.pid - The process number of the Ruby running this script.
    
    0 讨论(0)
  • 2021-01-28 00:33

    I made a wild guess it was can be process it. I validated it with

    Process.pid
    #=> returns the same value as $$
    

    PS: if there's more to it, please care to add your answer or comment.

    0 讨论(0)
提交回复
热议问题