Making array from hash values and call method with those arrays

I am converting a cucumber table into hash so I’ve this:

The table look like this:

| parameter | value |
| param1 | abc |
| param2 | def,jkl,xyz |

and step definition looks like this:

When /^I set params to$/ do |table|
h = table.hashes
puts h[0]
puts h[0].values_at(“param1”)

Its printing the below values for the last two line

{“parameter”=>“param1”, “value”=>“abc”}
[nil]

why is it printing nil for second line?

what I want to do is call a method with the values in value column as a
separate array for each row. like this :

method (h[0].values_at(“param1”),h[1].values_at(“param2”))

my method looks like this:

def method ( a=[], b=[])


end

can someone pls help?

Just an update

puts h[0].values_at(:param1)
puts h[1].values_at(‘param1’)

I’ve tried these two , but its printing [nil] for both. why does it give
me an array of nil value. it should give me [abc]

and for

puts h[0][:value]

it gives me abc , which is correct. but I need an array.

is it something special with values_at method? can someone pls help?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs