Ruby knows itself
An identity function according to wikipedia is defined as:
a function that always returns the same value that was used as its argument.
This morning I learned that Ruby added an identity function for objects in 2.2, #itself
!
> [1, 2, 3].map(&:itself)
[1, 2, 3]
Off the top of my head I can't think of a good example, but it does come up now and again. The identity function is definitely something to keep in mind!
Tweet