Multi-level struct manually



examples/struct/multi_level_struct_manually.cr
require "json"

struct Address
  getter street : String
  getter city : String
  getter country : String

  def initialize(@street, @city, @country)
  end
end

struct Person
  getter name : String
  getter email : String
  getter address : Address

  def initialize(@name, @email, @address)
  end
end

adr = Address.new("Main str. 3", "Capital", "Big")
pp! adr

prs = Person.new("Foo", "me@foo.bar", adr)
pp! prs

adr # => Address(@city="Capital", @country="Big", @street="Main str. 3")
prs # => Person(
 @address=Address(@city="Capital", @country="Big", @street="Main str. 3"),
 @email="me@foo.bar",
 @name="Foo")