Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

With Syntax

JeremySkinner edited this page Sep 13, 2010 · 1 revision

The ‘with’ keyword can be used to specify multiple operations upon a single variable or instance. For example, the following code creates an instance of the ‘Foo’ class and calls the “Bar” method on it:

f = Foo()
f.Bar()

…using ‘with’ this could be re-written as:

with f = Foo():
  .Bar()

…or simply as:

with Foo():
  .Bar()

This works nicely with Runnables.

Clone this wiki locally