Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Module#include

(::Module module, *::Module additional_modules) -> 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.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0