Skip to content

Programming Quote by Armando Fox

“When Ruby programmers say that some class “quacks like an Array,” they usually mean that it’s not necessarily an Array nor a descendant of Array, but it responds to most of the same methods as Array and can therefore be used wherever an Array would be used.” quote by Armando Fox
Download Open image
““When Ruby programmers say that some class “quacks like an Array,” they usually mean that it’s not necessarily an Array nor a descendant of Array, but it responds to most of the same methods as Array and can therefore be used wherever an Array would be used.””

Armando Fox

About This Quote

Source Talk: Programming Languages, Stanford CS 242, 2015

A class can be used like an Array if it implements the same methods, even without inheriting from Array.

In simple terms: Non‑Array class can act like an Array by matching its interface.

Key Takeaway

Design objects to match required interfaces.

Themes

polymorphism interface software design

Mood

technical analytical

Type

educational explanatory

When to use this quote

  • API design
  • library usage
  • code reuse
  • testing
  • refactoring

Key Concepts

duck typing method compatibility

Questions to Reflect On

  • What methods must your class implement to be interchangeable?
  • How does duck typing affect code safety?
A Different Perspective

If the class lacks subtle Array behaviors, substitution may fail.

4.7 out of 5 (5 ratings)

More by Armando Fox

Explore all 4 Armando Fox quotes

More Programming quotes

Browse all 6,476 Programming quotes