Duck Typing
You may have noticed that in Ruby you don’t explicitly declare the types of variables or methods. Whether the particular value of a variable is correct for the messages being passed to it’s evaluated at run time when the message is sent.
Folks tend to react to this in one of two ways. Some like this flexibility and feel comfortable writing code with dynamically typed variables and methods. Others get nervous when they think about all those objects floating around unconstrained. If you’ve come to Ruby from a language such as C#, Java, or TypeScript, where you’re used to giving all your variables and methods an explicit type, you may feel that Ruby is just too permissive for writing “real” applications.
It isn’t.
We’d like to spend ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access