Hacker News new | ask | show | jobs
by 0x0dea 3884 days ago
Ruby's Struct is pretty nifty.

    Person = Struct.new :name, :age

    people = [
      Person.new('Alice', 42),
      Person.new('Bob',   23),
      Person.new('Carol', 30)
    ]

    people.sort_by(&:age).map(&:name)
    # => ["Bob", "Carol", "Alice"]