cicloon
cicloon

Reputation: 1099

What does #{$$} inside a double quoted string in Ruby on Rails ?

I have a doubt concerning #{$$} inside a double quoted string, in concrete I have this string:

"#{command}#{$$}#{(Time.now.to_f * 1000).to_i}"

If I execute "#{$$}" in console I get an integer number but I would like to read an explanation to this.

Thank you !!

Upvotes: 0

Views: 99

Answers (2)

CambridgeMike
CambridgeMike

Reputation: 4622

That would be the global process ID.

If you're asking what the #{...} syntax means, that prints the variable inside the braces. So if it would work like this..

command = "print"
puts "cmd: #{command}" #=> cmd: print

Upvotes: 3

Ed Swangren
Ed Swangren

Reputation: 124712

$$ is the interpreter's process ID.

Ruby has quite a few global variables you can use, see here.

Upvotes: 8

Related Questions