A with
method for connection objects
which closes the connection after evaluation.
This is modelled after the common python idiom.
# S3 method for connection with(connection, expr)
connection | a connection, such as a file
connection created with |
---|---|
expr | expression to evaluate |
not_run({ connection <- file("file.csv", "r") with(connection, { print(connection) }) isOpen(connection) })