Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Extend struct

struct MyConfig
end

cfg = MyConfig.new
p! cfg
p! typeof(cfg)

struct MyConfig
  property name : String?
end

cfg.name = "Foo"
p! cfg
cfg # => MyConfig(@name=nil)
typeof(cfg) # => MyConfig
cfg # => MyConfig(@name="Foo")