I'm trying to translate some code from Python to Ruby but i'm stuck on this one function in python:
def notNoneOf(a, b):
return a is None and b or a
My naive translation into ruby is like this:
def notNoneOf(a, b):
return a.nil? and b || a
end
But this is giving me a void value expression
The usage of the function in the python code is as follows:
for m in re.finditer('<input.*?name=(?:"([^"]*)"|([^" >]*)) value=(?:"([^"]*)"|([^" >]*))[^>]*>', data):
formData[notNoneOf(m.group(1), m.group(2))] = notNoneOf(m.group(3), m.group(4))
From playing with the code in a python REPL, it seems like this ruby code should work:
def notNoneOf(a, b):
return a || b
end
But that seems like I'm missing some case for this?
This test in python makes it look like it's a bit different:
>>> a = None
>>> b = None
>>> notNoneOf(a,b)
>>>
Any help appreciated.