& would implicitly call #to_proc to convert the object to Proc object.
Any object that implements the to_proc method can be converted into a proc by the & operator, and therefore con be consumed by iterators. docs.ruby-lang.org/en/2.6.0/Proc.h...
But before 2.6, #to_proc that defined in Refinements are ignored at & operator.
That's correct!
&
would implicitly call#to_proc
to convert the object to Proc object.But before 2.6,
#to_proc
that defined in Refinements are ignored at&
operator.In 2.6, we can use
#to_proc
for&
operator.