Python has modules and packages, and packages have __init__.py file, so if I import a package called foo, the interpreter will look for foo/__init__.py.
I came across some ruby code that will include not a module but a directory: require 'core/utilts'. The core and utilts are directories, not single module files. What is the equivalent in ruby to the file __init__.py, or what are the files that are executed when I require a directory like this utilts dir? There are a lot of ruby files under it.
You can't import directories in Ruby. If you're running require 'core/utils', then there is a file called core/utils.rb. There might also be a directory called core/utils/ but it's utils.rb that is being included via require, and it will in turn likely includes files out of core/utils/.
So, the answer to your question is: No, there is no equivalent to foo/__init__.py, but the same thing can typically be accomplished with foo.rb which includes additional files in foo/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With