Can Ruby return nothing?

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

    Basically, what you are looking for is a statement. But Ruby doesn't have statements, only expressions. Everything is an expression, i.e. everything returns a value.

提交回复
热议问题