method_missing, ou répondre à ce qu'on n'a pas écritmethod_missing, or answering what you never wrote
Au bout de la chaîne d'ancêtres, quand rien n'a répondu, Ruby appelle method_missing. Le redéfinir intercepte les messages inconnus — mais jamais sans son jumeau respond_to_missing?, sinon l'objet ment au duck typing. Et seulement pour un ensemble ouvert : le connu se génère.At the end of the ancestor chain, when nothing answered, Ruby calls method_missing. Redefining it intercepts unknown messages — but never without its twin respond_to_missing?, or the object lies to duck typing. And only for an open set: the known is generated.
AudienceAudience
Dev tenté par l'objet magique, prêt à en mesurer le prixDev tempted by the magic object, ready to weigh its price
Le premier numéro est libre. Débloque tout The Ruby Loop —
tous les volumes, à vie — pour 5 €, paiement unique.
The first issue is free. Unlock all of The Ruby Loop —
every volume, forever — for €5, one-time.