Misha Moroshko
Misha Moroshko

Reputation: 171399

Is it possible to include multiple modules in a single "include" statement?

Is there a shorter way to do the following?

class MyClass
  include MyModule1
  include MyModule2
  include MyModule3
end

Upvotes: 25

Views: 8496

Answers (2)

Naren Sisodiya
Naren Sisodiya

Reputation: 7288

Try following

class MyClass
  include MyModule3, MyModule2, MyModule1
end

Edit: reversed the sequence

Upvotes: 34

elc
elc

Reputation: 1952

to get the same ancestry order you need to reverse the order in the one line version

class MyClass
  include MyModule3, MyModule2, MyModule1
end

Upvotes: 30

Related Questions