-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Dir.children #4808
Implemented Dir.children #4808
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight improvement to the spec is possible, looks good otherwise.
spec/std/dir_spec.cr
Outdated
it "lists children" do | ||
filenames = Dir.children(__DIR__) | ||
filenames.includes?(".").should be_false | ||
filenames.includes?("..").should be_false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about comparisons comparing the output to Dir.entries
here? Like checking that the size is the same minus two and that all returned items are also in the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example with size - 2
knows about implementation details, and should be not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhass done.
How about a yielding version? |
@RX14 I wouldn't mind but there's no yielding version of |
It would be nice to interate without allocating HEAP memory. I guess |
@ysbaddaden I concur, yet it sounds like a topic for a separate PR. |
@Sija Isn't the yielding version of |
@RX14 IIRC it comes from Ruby, but yeah, I'd say it is a bit confusing. Ruby has |
I think it's confusing having different names. We should have |
@RX14 and what should be |
What's currently |
@RX14 Why not two versions of |
@Sija Because that's not how we do naming of yielding/collection members. Think of The reason for the existing convention is that the name is more descriptive: |
@RX14 Fair point, it is more descriptive indeed. |
Closes #4807