Answer Posted / 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 |
Post New Answer View All Answers