

add Pathname#existence by timoschilling · Pull Request #43726 · rails/rails · Gi...
source link: https://github.com/rails/rails/pull/43726
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Summary
I would like to add Pathname#existence
, it's like Object#presence
but for file existence.
Often I see code like this:
content = Rails.root.join('file').read if Rails.root.join('file').exist?
With that the code can change to:
content = Rails.root.join('file').existence&.read
Recommend
-
8
Add `Enumerable#sole` by kivikakk · Pull Request #40914 · rails/rails · GitHub Copy link Contributor
-
7
New issue Add --css app generator option #43177
-
8
Copy link Member p8 commented...
-
6
git进阶(撤销pull、撤销merge、撤销add)1、撤销本次pullgit reflog
-
8
New issue Add try_reserve and try_reserve_exact for OsString #92338
-
13
Copy link FlixCoder commented...
-
7
Copy link Member
-
4
Is "Not intended to be called" any different from "it is UB to be called that way"? If 0 and -1 are the only possible values, the "returns the most significant bit (MSB...
-
5
New issue Add <[[T; N]]>::flatten{_mut} #95579
-
8
Conversation Contributor This P...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK