Add note on destructuring assignment

This commit is contained in:
Ryan Plant 2016-01-26 11:52:06 +11:00
parent 82cb669cd7
commit 0f5c74a79f

View File

@ -411,6 +411,15 @@ def guests(*array)
array.each { |guest| puts guest }
end
# If a method returns an array, you can use destructuring assignment
def foods
['pancake', 'sandwich', 'quesadilla']
end
breakfast, lunch, dinner = foods
breakfast # 'pancake'
dinner # 'quesadilla'
# Define a class with the class keyword
class Human