From: akr@... Date: 2016-11-05T07:25:39+00:00 Subject: [ruby-core:77958] [Ruby trunk Bug#12814][Rejected] Pathname#each_child(false) produces unusable file paths Issue #12814 has been updated by Akira Tanaka. Status changed from Feedback to Rejected Pathname#each_child is designed that easier access for child files by default (with_directory=true). But it is also possible to obtain filenames only (with_directory=false) for applications which remember the directory in the application (or application don't need the directory). If you need directory in pathname, you can use with_directory=true. If you don't want directory in pathname, you can use with_directory=false. ---------------------------------------- Bug #12814: Pathname#each_child(false) produces unusable file paths https://bugs.ruby-lang.org/issues/12814#change-61287 * Author: Mr. Tao * Status: Rejected * Priority: Normal * Assignee: * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`. ~~~ ruby Pathname.new('.').each_child { |f| p f.realpath } #��works as expected Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error ~~~ As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths. -- https://bugs.ruby-lang.org/ Unsubscribe: