Ruby, Scripting

Operator Overloading? Nada!

So today I got a perfect example of why operator overloading is such a nightmare.

What do you think this piece of Ruby means?

a << @b

The short answer is that it means nada. It will depend on both a and b and even if you learn what one instance of the operator means it will serve as no guide to identical operators for different types. This one operator resulted in a bug every time it was used and I don’t think it represents any value over a more verbose method call.

Standard

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 )

Facebook photo

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

Connecting to %s