3

add Pathname#existence by timoschilling · Pull Request #43726 · rails/rails · Gi...

 3 years ago
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.
neoserver,ios ssh client

Copy link

Contributor

timoschilling commented yesterday

edited

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK