what is the point of return in Ruby?

前端 未结 7 2148
日久生厌
日久生厌 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:26

    Its nice ruby gives this good feature of not specifying return statement explicitly but I just feel, as a programming standard, one should always strive to specify "return" statements wherever required. This helps in making code more readable for someone who is coming from different background like C++, Java, PHP etc. and learning ruby. "return" statement will not harm anything, so why skip conventional and more standard way of returning from functions.

提交回复
热议问题