It is very nice that it is easy to add my own methods to structs and classes and whatnot, but what protects me from accidentally replacing an existing method?
I know I can check if there is already such a method and then decide if I want to replace it with mine,
but what if a new version of the original object (struct, class etc.) gets a new method in an upgrade that I also used? Now I am overriding it.
I know I can write tests and I do, but I know a lot of people who don’t.
I tried the following and saw that neither Crystal not ameba warns me. Is there some other tool or some flag that would warn me that I am overriding an existing method?
struct Int def odd? return true end end puts 23.odd? puts 24.odd?
ps. I don’t expect it to tell me that my code doesn’t make sense at all