Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带webrick的Ruby字符串concat_Ruby - Fatal编程技术网

带webrick的Ruby字符串concat

带webrick的Ruby字符串concat,ruby,Ruby,我有一段代码要修改(ruby的新代码) 当我访问localhost:8080/test时,我得到一个 “没有这样的文件或目录C:\\{hRand}.html” 为什么不替换hRand?这是因为字符串插值仅适用于双引号字符串: File.read("C:\\#{hRand}.html") 哈哈!谢谢你,这让我头晕目眩。 File.read("C:\\#{hRand}.html")

我有一段代码要修改(ruby的新代码)

当我访问localhost:8080/test时,我得到一个

“没有这样的文件或目录C:\\{hRand}.html”


为什么不替换hRand?

这是因为字符串插值仅适用于双引号字符串:

File.read("C:\\#{hRand}.html")

哈哈!谢谢你,这让我头晕目眩。
File.read("C:\\#{hRand}.html")