I have a regular expression that returns multiple variables within a match. I am interested in the first non-null variable in a subset of indices within the match, so I am using
result = a[1] || a[3] || a[6] || ...
I would like to store the relevant indices in a configuration file along with the regular expression itself. What is the best shorthand notation that doesn’t obfuscate the meaning?
Use
values_atto get an array which contains only the elements at the specified indices. Then usefind {|x| x}to get the first element that is not nil or false.