I am filtering an array in ruby and using a .select block to do so. The conditions are sufficiently complex that a single line block is hideous but not that large so a separate method seems like overkill. Thus I want to use a multiline block. However I am unsure of the syntax.
filtered_array = base_array.select do |elem|
return false if condition1
return false if condition2
return true
end
The above is clearly incorrect as return exits the method, not the block but gives an idea of what I am looking for.
I could also use multiple select statements but that seems to obfuscate what I am trying to do. Note that the above conditions are sufficiently complex that using logical operators to bind them results in a mess.
What you want is
nextinstead ofreturn.