B
Brett Kruger
Hello, I'm very new to Ruby, and trying to follow the examples in
'Beginning Ruby' by Peter Cooper
However, I'm completely stuck right at the beginning, trying to work
with File.open
I have
line_count = 0
File.open("text.txt", "r").each { |line| line_count += 1 }
puts line_count
text.txt is in the same folder as my ruby file, and is ~ 100 lines of
text. However, line_count always outputs 0 for me.
I've tried changing the syntax around, but I really have no clue what
the problem may be.
'Beginning Ruby' by Peter Cooper
However, I'm completely stuck right at the beginning, trying to work
with File.open
I have
line_count = 0
File.open("text.txt", "r").each { |line| line_count += 1 }
puts line_count
text.txt is in the same folder as my ruby file, and is ~ 100 lines of
text. However, line_count always outputs 0 for me.
I've tried changing the syntax around, but I really have no clue what
the problem may be.