Can Ruby return nothing?

后端 未结 6 1276
没有蜡笔的小新
没有蜡笔的小新 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:21

    No, you can't return nothing. In ruby you always return something (even if it's just nil) - no way around that.

提交回复
热议问题