JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

with

core-api


    macro
    boot.janet on line 424, column 1

    (with [binding ctor dtor] & body)

    Evaluate `body` with some resource, which will be automatically 
    cleaned up if there is an error in `body`. `binding` is bound to 
    the expression `ctor`, and `dtor` is a function or callable that is 
    passed the binding. If no destructor (`dtor`) is given, will call 
    :close on the resource.


1 exampleSign in to add an example
Loading...
(os/shell "echo bar > /tmp/foo")
(with
  [file-handle
   (file/open "/tmp/foo")
   (fn [fd] (file/close fd))]
  (file/read file-handle :all))  # => @"bar\n"
cellularmitosisPlayground