config.vm.define 的命名和变量

Naming and variables of config.vm.define

教程中 https://docs.vagrantup.com/v2/multi-machine/

有几个代码示例,例如

config.vm.define :testing do |test|

config.vm.define "web" do |web|

在其中一些示例中,define 之后的字符串与 do (web, web) 之后的字符串相同,在某些情况下不是(测试,测试)。为什么?

此外,为什么在 "web" 中使用引号,而在 :testing 中使用冒号?

它比 vagrant 更 ruby 语言,但基本上 config.vm.define 是一个接受一个参数的方法,然后有一个 ruby block statement 并且在这个块中,方法参数有一个特定的在 |

之间定义的名称

Also, why use quotes with "web" but colon with :testing ?

作为一个ruby新手,我会说它是一样的——:x被称为symbols,你可以阅读some differences about using one or the other