I'm doing the following:
array_variable = collection.map do |param|
some value with param
end
return array_variable.compact
Can I call map
and compact
in one statement somehow, so I can return the result instantly?
I'm thinking on something like this (it may be invalid, however):
array_variable = block_code param.compact
# block_code here is a method for example which fills the array
Proc
object, and then you can call methods on it; butProc
s don't have acompact
method. (What does it even mean to "compact a block"?) – Bolingbrokecompact
) on the return value of another method (in this casemap
), but that is not what you are asking? Then, what is it you are asking and why did you accept an answer that answers a question you are not asking? – Bolingbroke