I have this hash :
hash = {:title=>"blabla", :content=>"blabla", :mark=>40}
In a loop I want to increment it with another pair of the same key => value objects.
What I want to have looks like this in PHP
hash = array(
0 => array(
'title' => 'blabla',
'content' => 'blabla',
'mark' => 50,
),
1 => array(
'title' => 'blabla',
'content' => 'blabla',
'mark' => 50,
)
);
And to have that I would loop like that
foreach ($elements as $element) {
$hash[] = array('title' => $element['title'],
'content' => $element['blabla'],
'mark' => $element['mark']
);
}
The []
after the variable name, auto increments the array in php, but it doesn't seem to act the same way with Ruby.
The expected Ruby ouput would be the following :
hash = {
{
'title' => 'blabla',
'content' => 'blabla',
'mark' => 50,
},
{
'title' => 'blabla',
'content' => 'blabla',
'mark' => 50,
}
}