In the following code:
def main
someArray.all? { |item| checkSomething(item) }
end
private
def checkSomething(arg)
...
end
How do I shorten the all? statement in order to ged rid of the redundant item variable?
I'm looking for something like someArray.all?(checkSomething) which gives a "wrong number of arguments" error.
itemvariable?#all?.. as it doesn't take any parameter as argument.. You have to go with block ..checkSomethingwithout any argument insomeArray.all?(checkSomething), that's why it complains.to_procshortcut (for example,ary.map(&:to_s)) does not apply here.