To read information from multiple files present in the same folder

my_text=“This is the first sentence and the second sentence doesn’t

words=my_text.split(" ")
words.each do |w|

my_hash.each do |k,v| puts k+" "+v.to_s end

#I need edit this code to read information from more files in same

I’m guessing you need my_test to be equal to a file’s contents. Do you
want it to be a single string formed from multiple files, or do you want
1 Hash per file?

Also, your current method doesn’t allow for punctuation and is
case-sensitive. Here’s an example of a Regexp which could improve it,
although you can’t account for every possibility :slight_smile:

The first thing you need to do is try for yourself. There no shortage of
examples of reading text files, and you haven’t even tried to do that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs