I'm doing a test with "require" under ruby 2.0.0p576 (2014-09-19 revision 47628) [x86_64-darwin13.4.0] it doesn't work in many ways. There are two files in ruby directory as shown below:
string_extensions.rb
class String def vowels self.scan(/[aeiou]/i) end end vowels_test.rb
require 'string_extensions' puts "This is a test".vowels.join('-') fire up IRB
Snailwalkers-MacBook-Pro:ruby snailwalker$ ruby vowels_test.rb returs : `require': cannot load such file -- string_extensions (LoadError) I tried to change require 'string_extensions' to " require_relative 'string_extensions' ; require './string_extensions.rb' . They all didn't work.
both return error : vowels_test.rb:1:in require_relative': /Users/snailwalker/Ruby/string_extensions.rb:1: class/module name must be CONSTANT (SyntaxError)
Your help will be greatly appreciated!
class/module name must be CONSTANT (SyntaxError), then there is a problem with your code, not withrequire.