Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

week 7 homework for Remy #121

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

week 7 homework for Remy #121

wants to merge 12 commits into from

Conversation

premy52
Copy link

@premy52 premy52 commented Nov 27, 2013

Closed old request, opened new one

@@ -3,7 +3,18 @@ Please Read Chapters 23 and 24 DuckTyping and MetaProgramming

Questions:
1. What is method_missing and how can it be used?
2. What is and Eigenclass and what is it used for? Where Do Singleton methods live?
3. When would you use DuckTypeing? How would you use it to improve your code?
1a. method_missing is a hook method called by the Ruby interpreter when a called method is not defined. That missing method can be defined by us to handle the method_missing condition with something useful to us, such as delivering a clearer diagnostic message or defining what the method should be in the absence of a definition. The method_missing definition substitutes itself as the (previously undefined) method that was called. This definition and substitution can be made conditional, but failures to all conditions should lead to an explicit call to "super" to forward the call to superclasses so that the failure to find the called method results in an error message rather than being silently ignored. method_missing can also be used to create customized methods on the fly using conditions (such as pattern recognition with Regexp's) that analyze incoming arguments to build or choose the method that becomes the called method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants