Sunday, June 21, 2015

Implicit Vs Explicit Return in Ruby

You can run the following code at RubyPlus Code Editor:

Implicit return:

def times_ten(integer)
  integer * 10
end

p times_ten(1)

Explicit return:

def times_ten(integer)
  return integer * 10
end

p times_ten(2)