class B prepend A # <-‐ prepend instead of include def foo; puts "B"; end end klass = B.new klass.foo # => "A" B.ancestors # => [A, B, Object, Kernel, BasicObject] Module#prepend
end end class A def foo_with_bar foo_without_bar puts "bar" end alias_method_chain :foo, :bar end A.new.foo # => "foo bar" A.ancestors # => [A, Object, Kernel, BasicObject] Module#prepend
module Extension def foo super puts "bar" end end class A prepend Extension end A.new.foo # => "foo bar" A.ancestors # => [Extension, A, Object, Kernel, BasicObject] Module#prepend
without_lazy { range. map { |el| el * 2 } } with_lazy { range.lazy.map { |el| el * 2 }.to_a } end # Running each test 256 times. # without_lazy is faster than with_lazy by 4x ± 0.1