Skip to content
class method

File.open

(::string | ::_ToPath | ::int file_name, ?::string | ::int mode, ?::int perm) -> instance
[T] (::string | ::_ToPath | ::int file_name, ?::string | ::int mode, ?::int perm) { (::File) -> T } -> T
File.open(path, mode = 'r', perm = 0666, **opts) → file
File.open(path, mode = 'r', perm = 0666, **opts) {|f| ... } → object

Creates a new File object, via File.new with the given arguments.

With no block given, returns the File object.

With a block given, calls the block with the File object and returns the block’s value.

See also .new .owned? .mtime .path also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0