I would like to have this as a feature in the language without having to import another "magic" module, something similar to case classes in Scala.
Let me dream :)
Let me dream :)
https://hg.python.org/cpython/file/tip/Lib/collections/__ini...
I would settle for better namedtuple syntax though.
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"]