10 Jun 2022   ruby


Hash#invert returns a new Hash object with the each key-value pair inverted:

{first: 1, last: 2}.invert
=> {
  1 => :first,
  2 => :last
}
{first: 1, last: 2}.invert[2]
=> :last
🍄