-1
我是ruby的新手,想要了解如何传递与ruby中的键相对应的值。 我有一个散列rubylike如下─ruby如何通过哈希值传递值
instance1
shutdown_port: 1234
startup_port: 1678
instance2
shutdown_port: 2234
startup_port: 2678
我想通过shutdown_port
和startup_port
每个实例的方法,但不想混shutdown_port
& startup_port
值。
类似的,if keyname = shutdown_port
,通过相应的值和if if keyname = startup_port
,通过相应的值。
“我在rubylike哈希” - 这看起来并不像红宝石哈希,在所有。 –
其实我正在写一个厨师食谱,这就是我将通过我的.kitchen.yml。我需要为每个实例读取“shutdown_port”和“startup_port” – user6378152
这也不是有效的yaml。即使是这样,你也应该让我们摆脱这个实现细节。最终你会将它解析为散列。发布有效的散列。 –