How to open a file in Ruby?
Answer / Janpriya Gaur
To open a file in Ruby, you can use the File.open method. For example: File.open('filename.txt', 'r') { |file| file.each_line do |line| puts line end } This opens the file with read-only access and iterates through each line printing it.
| Is This Answer Correct ? | 0 Yes | 0 No |
Tell us how would you implement hash in ruby internally?
Tell me what is the difference between ruby 1.9 and ruby 2.0?
Please explain the three levels of access control for ruby methods?
Tell me how can you declare a block in ruby?
Tell me how you can list all routes for an application?
How to use ruby methods.
Tell me how you can create a controller for subject?
Explain about Float, Dig and Max?
Tell us what is the difference between dynamic and static scaffolding?
What is concatenating string in ruby. In how many ways you can create a concatenating string.
difference between activesupport's “hashwithindifferentaccess” and ruby's “hash”?
Explain Ruby module?