• +91 9723535972
  • info@interviewmaterial.com

Ruby Interview Questions and Answers

Question - How to read a file in Ruby?

Answer -

There are three different methods to read a file.

To return a single line, following syntax is used.

Syntax:

f.gets  
code...  
To return the whole file after the current position, following syntax is used.

Syntax:

f.rea  
code...  
To return file as an array of lines, following syntax is used.

Syntax:

f.readlines  
[code...]  

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners