ruby-uebungen/Assignment_027/solution/readme.md

21 lines
233 B
Markdown
Raw Normal View History

2023-05-25 17:47:19 +02:00
# Lösung: Klasse Dir und IO
2023-05-25 17:49:42 +02:00
```ruby
2023-05-25 17:47:19 +02:00
def print(f)
n = 0
puts f, "\n"
IO.foreach(f) do |line|
puts "%4d %s" % [ n, line ]
n += 1
end
puts "\n\n"
end
Dir.foreach('.') do |f|
print f if /.*\.txt$/ =~ f
end
```