Code & Clay Notes to self. Mainly Ruby/Rails.

Object#itself

Object has a method named #itself. It returns the object it’s called on:

> Object.new.itself
=> #<Object:0x00007ffd9dd9df58>

"Hello".itself
=> "Hello"

For example:

> [1,1,2,3,3,3,4,5,5,6].group_by(&:itself)
=> {1=>[1, 1], 2=>[2], 3=>[3, 3, 3], 4=>[4], 5=>[5, 5], 6=>[6]}