Un atelier Ruby · Édition d'ApprentissageA Ruby Workshop · Learning Edition

Les protocoles implicites Implicit protocols

Le duck typing dit « réponds au message » — mais lesquels ? Ruby en attend certains sans jamais les déclarer : to_s, <=>, each, hash. Fournis le bon hook et inclus le mixin, et tu obtiens des familles entières de méthodes. Une « interface » que personne n'a écrite, et un marché : un hook contre une famille. Duck typing says 'answer the message' — but which? Ruby expects some without ever declaring them: to_s, <=>, each, hash. Provide the right hook, include the mixin, and you get whole method families. An 'interface' nobody wrote, and a bargain: one hook for a family.

AudienceAudience
Dev à l'aise avec le duck typing, prêt à brancher ses objets sur la std Dev comfortable with duck typing, ready to wire objects into the stdlib
Format
Self-paced
ChapitresChapters
5
Date
Fév 2026 Feb 2026
≈ 18 min ●●○○ ProtocoleComparableEnumerable
🔒

La suite est réservée The rest is members-only

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.

Retour au kiosqueBack to newsstand