Empty struct


Structs are very powerful constructs in Crystal. Very similar to classes, but they are usually faster.

In the first example we create an empty struct. It does not give as a lot, but we have to start somewhere.


examples/struct/empty_struct.cr
struct MyConfig
end

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

cfg # => MyConfig()
typeof(cfg) # => MyConfig