Would you prefer this:
def add(a, b)
puts "ADDING #{a} + #{b}"
return a + b
end
over this?
def add(a, b)
puts "ADDING #{a} + #{b}"
a + b
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s The Ruby Way™ to not include the
returnstatement unless it’s absolutely required.I’m sure there’s better examples, but here’s a simple one.
It’s worth noting that Ruby provides means to optionally ignore a lot of syntax.
()are optional unless you’re nesting them.{}can be omitted in many cases too.You’ll learn a lot more shortcuts as you go.