3 ms·
I don't like the OP code either. To someone not familiar with this language, || produces a boolean value (true or false), and that value gets assigned to param.
by codehalo 14y ago
I don't like the OP code either. To someone not familiar with this language, || produces a boolean value (true or false), and that value gets assigned to param. A better approach would be (without knowledge of the language in particular):
def method (object)
param = default_param
if object.property
param = object.property
end
end
Here, its clear that param has a default right away.