summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorRyan Plant <ryan@ryanplant.net>2016-01-26 11:52:06 +1100
committerRyan Plant <ryan@ryanplant.net>2016-01-26 11:52:06 +1100
commit0f5c74a79f328aa1b385a2dae3389d48faa47ce5 (patch)
tree0d00cbd284946549484bcf269671f3e3927b7982 /ruby.html.markdown
parent82cb669cd77e0b394be0161ea8c688aa78f955d6 (diff)
Add note on destructuring assignment
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown9
1 files changed, 9 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 24dd788a..6743de6b 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -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