Search Results

Search found 1 results on 1 pages for 'user612308'.

Page 1/1 | 1 

  • Ruby: reduce duplication while initialize hash

    - by user612308
    array = [0, 0.3, 0.4, 0.2, 0.6] hash = { "key1" => array[0..2], "key2" => array[0..3], "key3" => array, "key4" => array, "key5" => array, "key6" => array, "key7" => array } Is there a way I can remove the duplication by doing something like hash = { "key1" => array[0..2], "key2" => array[0..3], %(key3, key4, key5, key6, key7).each {|ele| ele => array} }

    Read the article

1