Let's Learn Return

Sometimes we don't just want a method to print something to the console, 
but we actually want that method to hand us (or another method!) back a 
value. For that, we use return.

def double(n)
  return n * 2
end

output = double(6)
output += 2
puts output

    1. In the example above, we define a new method called double that 
accepts one argument called n.
    2. Inside the method, we return two times n.
    3. After that, we call our new double method with an argument of 6 and 
store the result, 12, in output.
    4. Then, we increase output to 14 and print it out to the console. 


-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to