I have this array:
[["RESULT", "1"], ["RESPMSG", "User authentication failed"]] I want to access the RESPMSG element of the array and print its value, which can change, but its name is constant.
Any idea how I can print the array element by name? I tried like this, but I miss something:
decoded = URI::decode_www_form(@response_body, enc=Encoding::UTF_8) respmsg = decoded.index("RESPMSG") puts respmsg The main problem is that RESPMSG is not always at the position 1 in the array, otherwise would be easier.
Hashinstead? If you're trying to print out the value of"RESULT"as1then a Hash is almost definitely what you're looking for. If this is the case, let me know and I'll leave an answer.