method

existence

Importance_1
v7.0.0 - Show latest stable - 0 notes - Class: Pathname
existence() public

Returns the receiver if the named file exists otherwise returns nil. pathname.existence is equivalent to

pathname.exist? ? pathname : nil

For example, something like

content = pathname.read if pathname.exist?

becomes

content = pathname.existence&.read

@return [Pathname]

Show source
Register or log in to add new notes.