|
|
|
|
|
by byroot
797 days ago
|
|
> Raising an error when at runtime you call a nonexistent method is native Ruby behavior, so why write methods that say "I don't exist"? Well, first for documentation as you pointed. Second because otherwise the error is a `NoMethodError` which inherits from `StandardError` hence may be casually rescued. > Ruby also provides inheritance hooks that could conceivably be used to detect the existence of methods at load time It's not every practical because the hook is called while the child class is opened, so no method is yet implemented into it. You'd need to collect all the child class and then check they implement all the necessary methods at a later point when you are done loading, which isn't a clearly defined point in a general Ruby program. |
|