The unless is ruby is equivalents to if not
Sample code
1: fileName = 'C:\\learn\\Ruby\\TestFiles\\myTest.txt'2: f = File.open(fileName, "r")3: f.each_line do |line|4: next unless line =~ /\d{2,6}/ # Skip lines with no numbers with len < 25: puts line6: end
Input data
13333333333333333333333333333
2
3
4
Zvika
5
6
7
Shaaf
And the result
C:\learn\Ruby>test5.rb
2
3
4
Zvika
5
6
7
Shaaf
אין תגובות:
הוסף רשומת תגובה