We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a14bcb commit a2e9e33Copy full SHA for a2e9e33
guides/source/active_support_core_extensions.md
@@ -4055,3 +4055,18 @@ end
4055
NOTE: Defined in `active_support/core_ext/load_error.rb`.
4056
4057
[LoadError#is_missing?]: https://api.rubyonrails.org/classes/LoadError.html#method-i-is_missing-3F
4058
+
4059
+Extensions to Pathname
4060
+-------------------------
4061
4062
+### `existence`
4063
4064
+The [`existence`][Pathname#existence] method returns the receiver if the named file exists otherwise returns +nil+. It is useful for idioms like this:
4065
4066
+```ruby
4067
+content = Pathname.new("file").existence&.read
4068
+```
4069
4070
+NOTE: Defined in `active_support/core_ext/pathname/existence.rb`.
4071
4072
+[Pathname#existence]: https://api.rubyonrails.org/classes/Pathname.html#method-i-existence
0 commit comments