17 DYNAMIC PROGRAMMING

All programming languages are capable of some flexibility, whether it’s responding to user input or merely using basic control structures. Ruby excels in this area, though, as Ruby scripts can be dynamic in ways that most other programming languages cannot. Through metaprogramming, reflection, functional programming, and the like, Ruby code can be truly dynamic. While thorough examination of these topics is well beyond the scope of a beginner’s guide to Ruby (and, to be fair, not every Ruby programmer needs to use these techniques), this chapter will introduce these and other topics in this same vein.

To start, the first subject shows how you can write code that behaves differently, depending upon the operating system ...

Get Ruby: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.