crystal-book icon indicating copy to clipboard operation
crystal-book copied to clipboard

Documentation for `include` inside lib structs

Open HertzDevil opened this issue 6 months ago • 0 comments

You can do this since https://github.com/crystal-lang/crystal/commit/a8dc4fb81ddb0881281fa4617c4237a5a5e908ad:

lib Lib
  struct Foo
    x : Int32
    y : Int16
  end

  struct Bar
    include Foo
    z : Int8
  end
end

Lib::Bar.new # => Lib::Bar(@x=0, @y=0, @z=0)

I don't know if this has ever been used in the wild at all, but we should probably document it regardless.

HertzDevil avatar Dec 14 '23 17:12 HertzDevil