Why I couldn't require 'string.rb' file in ruby -
I am applying the gem, I want to add some custom methods to the string class. Therefore, I have created the 'lib' directory sub-directory 'core_ext', and placed the 'string.rb' file there. I have created in my main file: If I change the file name to another name, like 'my_string.rb' and change the line with requirement, then everything will work properly. Why can not I use 'string.rb' as the file name? If there is a file name Ruby 1.9 has a
is required 'core_ext / string.rb' P> but its string has no effect on class,
core_ext / string which loads from anywhere else It's done, it is also loaded one. You may need to come up with a different name.
needed_relative feature that p11y states that this is a better solution.
Comments
Post a Comment