From: Francisco Martinez Date: 2010-07-10T03:01:51+09:00 Subject: Re: FIRST PROGRAMMING PROBLEM Array unknown wrote: > On Fri, Jul 9, 2010 at 1:22 PM, Francisco Martinez > wrote: >> Hi...I'm trying to solve a very simple exercise but this is one of my >> first tasks and I can't manage to find a solution. >> I have a txt file and I have to write a method which; given the txt file >> as an entry argument returns an array of tokens. I have to call the >> method that prints �the solutin in the screen. >> The solution should be this type: >> >> token 1= The >> token 2= man >> token 3= was > > How far have you made it? > * read from the file > * get the tokens from the file > * put the tokens into an array > * display the output I Have done It: num=1 File.open("text.txt") puts "token#{num}= #{nom}" num=num+1 end it reads the wole text not considering each word or "." but reading each line...I need to put it in a method that calls "text.txt" and to use an array and the result must be each line one word. -- Posted via http://www.ruby-forum.com/.