Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Module#include

(::Module, *::Module arg0) -> self
include(module, ...) → self

Invokes Module.append_features on each parameter in reverse order.

Ruby version changes

  1. 3.0
    • Module#include and Module#prepend now affect classes and modules that have already included or prepended the receiver, mirroring the behavior if the arguments were included in the receiver before the other modules and classes included or prepended the receiver. [Feature #9573]

      Example
      class C; end
      module M1; end
      module M2; end
      C.include M1
      M1.include M2
      p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]
      
See also #include? #freeze #extend_object #included also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0