1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-16 19:54:38 +02:00

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 } array.each { |guest| puts guest }
end 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 # Define a class with the class keyword
class Human class Human