put this code in a file called string_extensions.rb: : require « Language Basics « Ruby






put this code in a file called string_extensions.rb:


class String
  def vowels
    self.scan(/[aeiou]/i)
  end
end

# And put this code in a file called vowel_test.rb:

require 'string_extensions'
puts "This is a test".vowels.join('-')

 








Related examples in the same category

1.Test require command
2.A commonly used shortcut uses arrays to quickly load a collection of libraries at once.
3.Nested Inclusions