Ruby array of two dimensional arrays, search/lookup? -
this may simple, don't know of ruby's array functions.
if have given array like:
values = [["a", 1], ["b", 3], ["c", 7], ... etc ] i 2 functions:
a function that, when give "b", gives me 3. the other way around, function when give 3, gives me "b".there must easy way?
hash = array.to_h => converts array hash hash[key] = value => value associated key hash.invert[key] = value => method inverts hash , can select values
ruby arrays
No comments:
Post a Comment