what is the point of return in Ruby?

前端 未结 7 2160
日久生厌
日久生厌 2020-12-02 18:20

What is the difference between return and just putting a variable such as the following:

no return

def write_code(number_of_errors)
           


        
7条回答
  •  广开言路
    2020-12-02 18:46

    Unnecesarity of return at the last line in function is just syntaxic sugar of Ruby. In most procedural languages you need to write return in each (non-void in C++) function.

提交回复
热议问题