Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Ruby On Rails Interview Questions and Answers

Ques. How can you achieve the same as Multiple Inheritance using Ruby? What is Mixin?
Ruby offers a very neat alternative concept called mixin. Modules can be imported inside other class using mixin. They are then mixed-in with the class in which they are imported.

Here’s an example:

module Debug
  def whoAmI?
    "I am #{self.to_s}"

class Photo
 include Debug

ph = Photo.new

"I am : #<Photo:0x007f8ea218b270>"

As you can see above the class Debug and it’s method “whoamI?” were mixed-in (added) with the class Photo.

That’s why you can now create an instance of the Photo class and call the whoAmI? method.

 => "I am : #<Phonograph:0x007f8ea218b270>" 
Is it helpful? Yes No

Most helpful rated by users:

©2016 WithoutBook