mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-17 12:10:52 +02:00
Add note on destructuring assignment
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user