When you put a Proc pr object with & at the position of the last argument, for example, in:
some_method(&pr)
then the block corresponding to pr will be passed to some_method . If the non_pr object, which is not Proc , is specified as:
some_method(&non_pr)
then non_pr will be implicitly converted to Proc on to_proc .
For example, when non_pr is Symbol , then Symbol#to_proc , which happens something like this:
class Symbol def to_proc proc{|obj, *args| obj.send(self, *args)} end end
In particular, with each(&:delete_all) :delete_all.to_proc will return a Proc object:
proc{|obj, *args| obj.delete_all(*args)}
therefore, the corresponding block will be passed to each as follows:
each{|obj, *args| obj.delete_all(*args)}
Noticing that the block arity for Enumerable#each is single, this is simplified:
each{|obj| obj.delete_all}
source share