Move the String#val_for logic to Array#val_for so it's available on both.