How could I compact this logic?
an_array = some_list.select do |item|
include_item = true
if a_boolean
include_item = a_method?(item)
end
include_item
end
I urge you to post some more sensible examples; meta-variables lead into the dark side. In your case, In your case, if
a_booleanisfalse, the code basically evaluatesan_array = some_list.clone, but in slow motion. Thus, it would be more sensible to writeAnd I still have no clue if it’s actually good, because your intention is completely impenetrable by using overgeneric code.
EDIT: Added
.clone.EDIT2: As noted in comments, meagar and my meandering brain eventually arrived at the sameish place: