what is the point of return in Ruby?

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

    Ruby returns always! the best way is

    def write_code(number_of_errors)
      (number_of_errors > 1)? "ERROR" : "No Problem"
    end
    

    it means that if number_of_errors > 1 it will return ERROR else No Problem

提交回复
热议问题