Why does the :: select private object exist? Where do the methods of public selection come from?

This was common when I noticed this little gem:

> nil.select

NoMethodError: private `select 'method for nil: NilClass

Why does nil have a private select method?

I also noticed that Array.methods and Enumerable.methods does not have :select , so when do they come from?

+2
source share
1 answer

From the Kernel module, which is part of the Object class. NilClass is the parent of the Object , then include the form Object and Kernel methods

Kernel module has a selection method.

+1
source

Source: https://habr.com/ru/post/958009/


All Articles