Can Ruby return nothing?

后端 未结 6 1274
没有蜡笔的小新
没有蜡笔的小新 2021-02-12 17:53

Can I return nothing in ruby?

Just for educational purpose

For example:

myarray = [1,2,3]
myarray << some_method

def some_method
         


        
6条回答
  •  [愿得一人]
    2021-02-12 18:01

    Nothing does not mean anything to ruby from what i know :) You can define your own nothing though and throw it as much as possible. In ruby, if you do not explicitly return something, the last evaluated expression is returned.

提交回复
热议问题