Last active
December 19, 2015 07:59
-
-
Save xiy/5922482 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define the empty variable text | |
text ='' | |
#define the line_count variable as 0. | |
line_count = 0 | |
#open the text file I am working with, and use the each method to iterate | |
#each line and place it into the variable 'line' | |
File.open("text.txt").each do |line| | |
#add 1 for each line during each iterated line. (Loop until each line is processed?) | |
line_count += 1 | |
#add each line to the text variable - not sure why this is line, not line_count?! | |
text << line | |
end | |
#print the total count | |
puts "#{line_count} lines" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment