-
-
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
Add File#rename
#13640
Add File#rename
#13640
Conversation
Like File.rename, but updates the `@path` of the instance
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.
Looks reasonable 👍
# Rename the current `File` | ||
def rename(new_filename : Path | String) : Nil | ||
File.rename(@path, new_filename) | ||
@path = new_filename.to_s |
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.
Do the both cases the same?
new_filename
could be just a file name (as the test covers)) but could be a (full) path...
BTW is @path
a (stringified) path or a file name?
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.
@path
is whatever you pass to the constructor. It can be a single file name or consist of multiple path components. It makes no difference which.
Like File.rename, but updates the
@path
of the instance