Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

Common ways to read a file in Ruby?

scmuser created the topic: Common ways to read a file in Ruby?

[code language=”css”]
File.open(“my/file/path”, “r”) do |f|
f.each_line do |line|
puts line
end
end
# File is closed automatically at end of block
[/code]

It is also possible to explicitly close file after as above (pass a block to open closes it for you):

[code language=”css”]
f = File.open(“my/file/path”, “r”)
f.each_line do |line|
puts line
end
f.close
[/code]

Source – stackoverflow.com/questions/5545068/what…-read-a-file-in-ruby

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x