..


Sponsored Links

How do I read the contents of a file with Ruby?

To read the contents of the file you can use a simple loop:

 



 # Opening and reading a text file







 File.open ('test.txt', 'r') do | read |







 while line = leggi.gets



  



 puts line







 # End of while loop







 end







 # End of method call







 end

 

In the same category ...
E-Learning
Ruby and Ruby on Rails (Course) Ruby and Ruby on Rails (Course)
Create software and Web applications with Ruby and RoR. From 39 €.
Sponsored Links