Reputation: 1742
I've been trying to learn Ruby, and I recently reoccuringly saw something like this in a few people's Github repo:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/ubuntu-15.04-snappy-core-edge-amd64"
config.vm.network "forwarded_port", guest:80, host:8080
end
Why is there no assignment operator after config.vm.network? Is this non-standard Ruby? Or are they passing arguments in a function? What's going on here?
Upvotes: 1
Views: 48
Reputation: 1124
Your guess is correct. The config.vm
object has a network
method. The Ruby syntax is pretty relaxed, but this call can be written more "formally" like
config.vm.network("forwarded_port", {guest: 80, host: 8080})
This relaxed form that you are seeing often is a common convention. (Hence why you are seeing it quite often!)
Hope this helps.
Upvotes: 2