简体   繁体   English

在Ruby on Rails中双引号字符串中的#{$$}是什么?

[英]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 !! 谢谢 !!

$$ is the interpreter's process ID. $$是解释程序的进程ID。

Ruby has quite a few global variables you can use, see here. Ruby有很多可以使用的全局变量, 请参见此处。

That would be the global process ID . 那将是全局进程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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM