Complete the code to include the module for instance methods.
module Greetings def hello "Hello!" end end class Person [1] Greetings end p = Person.new puts p.hello
In Ruby, include adds module methods as instance methods to a class.
Complete the code to call the instance method from the included module.
module Farewell def goodbye "Goodbye!" end end class Friend include Farewell end f = Friend.new puts f.[1]
The instance method defined in the module is goodbye, so calling f.goodbye works.
Fix the error by completing the code to include the module correctly.
module Helper def assist "Assisting" end end class Worker [1] Helper end w = Worker.new puts w.assist
To add instance methods from a module, use include. extend adds class methods.
Fill both blanks to define a module and include it for instance methods.
module [1] def greet "Hi!" end end class User [2] GreetModule end u = User.new puts u.greet
The module name is GreetModule and it is included using include to add instance methods.
Fill all three blanks to create a module, include it, and call its instance method.
module [1] def welcome "Welcome!" end end class Member [2] WelcomeModule end m = Member.new puts m.[3]
The module is named WelcomeModule, included with include, and the instance method welcome is called on the object.