Refinements take place at block passing. [Feature #14223]
https://github.com/ruby/ruby/blob/v2_6_0/NEWS
It's very useful when you want to use th...
For further actions, you may consider blocking this person and/or reporting abuse
&o.:[]the amount of sugar in these 6 symbols gave me diabetes.140% symbols😋🍭
map(&o.:[])(&.:[])map{|k|o[k]}{|[]}I don't have a damn idea what I am looking at.
My guess is
&1is1.to_proc()andois the receiver object (e.g.a.map(&0)would doa.map( -> a[0])) and the sugar diabetes thingy isa.[].to_proc(). If I'm wrong please correct me @hanachin .There's something similar in Kotlin though I like their implementation more.
That's correct!
&would implicitly call#to_procto convert the object to Proc object.But before 2.6,
#to_procthat defined in Refinements are ignored at&operator.In 2.6, we can use
#to_procfor&operator.