07-19-2023, 01:34 AM
Can I return nothing in ruby?
*Just for educational purpose*
For example:
myarray = [1,2,3]
myarray << some_method
def some_method
if Date.today.day > 15
return "Trololo"
else
return __NOTHING__
end
end
So if today is 11'th March `myarray` won't add new item. I don't want `nil` - because `nil` is not nothing :)
And I understand, that I can use `if | unless` statement like `myarray << some_method if some_method` etc. I want to understand can I return __nothing__ or every time in ruby I am returning __something__ (least I can get is Nil Object)
*Just for educational purpose*
For example:
myarray = [1,2,3]
myarray << some_method
def some_method
if Date.today.day > 15
return "Trololo"
else
return __NOTHING__
end
end
So if today is 11'th March `myarray` won't add new item. I don't want `nil` - because `nil` is not nothing :)
And I understand, that I can use `if | unless` statement like `myarray << some_method if some_method` etc. I want to understand can I return __nothing__ or every time in ruby I am returning __something__ (least I can get is Nil Object)