Archive of August 2016

Refinements has been added to Ruby to replace popular, but bad approach called Monkey Patching.

Let's check what Monkey Patching is and why it is bad.

For example, we have a class User, which has method to_s:

The best way to understand how Module#prepend works is to figure out method lookup process in Ruby.

If it's a simple inheritance and method is present in parent class but not in a main class:

Ruby is not a strong typed programming language, so methods can accept arguments of any type. But sometimes we want to make sure that value we accept is an Array.

I've seen many times that developers do something like that: