mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Add note on destructuring assignment
This commit is contained in:
parent
82cb669cd7
commit
0f5c74a79f
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user