Ruby - Modules and MixinsWhich of the following is true about methods added by include in Ruby?AThey become private methods of the classBThey become instance methods of the classCThey become singleton methods of the moduleDThey become class methods of the classCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall what include doesIt mixes in the module's instance methods as instance methods of the including class.Step 2: Understand method visibilityBy default, included methods are public instance methods, not private or class methods.Final Answer:They become instance methods of the class -> Option BQuick Check:Include = instance methods [OK]Quick Trick: Include adds public instance methods by default [OK]Common Mistakes:Assuming included methods become privateConfusing instance and class methodsThinking methods become singleton methods
Master "Modules and Mixins" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Classes and Objects - Object identity (equal? vs ==) - Quiz 14medium Enumerable and Collection Processing - Sort_by for custom sorting - Quiz 5medium Error Handling - Exception hierarchy - Quiz 1easy Error Handling - Custom exception classes - Quiz 4medium File IO - File.read for entire content - Quiz 9hard File IO - Dir operations for directories - Quiz 9hard File IO - File.read for entire content - Quiz 5medium Inheritance - Why single inheritance in Ruby - Quiz 4medium Modules and Mixins - Prepend for method chain insertion - Quiz 5medium Modules and Mixins - Prepend for method chain insertion - Quiz 1easy