Dynamic method calls in Ruby

Ruby is a dynamic language. One of the coolest feature is the dynamic method call. Image you have a Integer Object.

a = 5

On every Object you can call the “to_s” method, that will convert it to String.


Will return the String representation of 5 that is “5”. But you can also call the method in a dynamic way:


That is cool! Int that way you can make method calls dynamically and configurable.

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: