From: Josh Cheek Date: 2011-09-12T07:20:34+09:00 Subject: Re: making an array of strings --20cf3071cd34970fd904acb1d16c Content-Type: text/plain; charset=ISO-8859-1 On Sun, Sep 11, 2011 at 9:58 AM, Zipizap zipizap wrote: > > # B- The same using %w - it splits a string into words, and returns an > array. Notice also that () is used to delimit the string, instead of "" > str_arr = %w(boy girl cat dog) # => ["boy", "girl", "cat", "dog"] > > The delimiters are arbitrary, so you can use quotes if you want. %w"boy girl cat dog" # => ["boy", "girl", "cat", "dog"] On Sun, Sep 11, 2011 at 9:00 AM, Joe Collins wrote: > Also, I want to read words from a file and make them an array of > strings. I can read files fine but making an array of strings is where I > am > stumped. > > My answer would change depending on some variables like how big your file is and whether the words are each on their own line or if there is one line with spaces between each, or if there are lots of lines with lots of words one each, so might be beneficial to provide more information. --20cf3071cd34970fd904acb1d16c--