Immutable struct with getter macro
We can use the getter macro to create getters to all of the attributes.
examples/struct/immutable_struct_with_getter_macro.cr
struct Person getter name, email def initialize(@name : String, @email : String) end end foo = Person.new("Foo", "me@foo.bar") p! foo p! foo.name p! foo.email
foo # => Person(@name="Foo", @email="me@foo.bar") foo.name # => "Foo" foo.email # => "me@foo.bar"