mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00

* Refactor dir.rb sample The original (1998) sample with a for-loop and use of case/when isn't what we'd write nowadays * [DOC] Update sample/dir.rb [ci skip] Do not leave a `Dir` opened. * [DOC] Update sample/dir.rb [ci skip] Fix ArgumentError. --------- Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
7 lines
161 B
Ruby
7 lines
161 B
Ruby
# directory access
|
|
# list all files but .*/*~/*.o
|
|
Dir.foreach(".") do |file|
|
|
unless file.start_with?('.') or file.end_with?('~', '.o')
|
|
puts file
|
|
end
|
|
end
|