I’m trying to write my code more compact. I have three hashes. The first hash (@hash) is a collection of sub-hashes (value_1, value_2)
@hash = {
"Key" => ["value_1", "value_2"]
}
@value_1 = {
"Foo" => ["bar_1", "bar_2"]
}
@value_2 = {
"Foo2" => ["bar2_1", "bar2_2"]
}
Now, in my haml-view i’m trying to make something like this:
- i = 0
- @hash.each_value do |value|
- @value_[i].each_pair do |k, v|
= k
= v[0]
- i = i +1
I don’t want to write one hash after the other. It’s a bit similar to making a symbol out of a string, where you can write somthing like “value_#{i}”.to_sym. I hope, somebody can follow and help me.
Then
And if you need the index use
each_with_index.EDIT
Try this:
API