Destructuring with Ruby
If a method returns an array, you can use destructuring for variable assignment.
def foods
['pancake', 'sandwich', 'quesadilla']
end
breakfast, lunch, dinner = foods
breakfast #=> 'pancake'
dinner #=> 'quesadilla'
⬅️ Read previous Read next ➡️