Using

com.thoughtworks.dsl.keywords.Using$package$.Using$
object Using

Attributes

Source
Using.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Using.type

Members list

Type members

Classlikes

trait ScopeExitHandler extends AutoCloseable

Attributes

Source
Using.scala
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any

Value members

Concrete methods

Returns a Using keyword to execute a ScopeExitHandler when exiting the nearest enclosing scope that is annotated as @reset, (or the nearest enclosing function if compilerplugins.ResetEverywhere is enabled).

Returns a Using keyword to execute a ScopeExitHandler when exiting the nearest enclosing scope that is annotated as @reset, (or the nearest enclosing function if compilerplugins.ResetEverywhere is enabled).

Attributes

Note

This method is similar to apply, except the parameter type is changed from a generic R to the SAM type ScopeExitHandler, which allows for function literal expressions in Scala 2.12+ or Scala 2.11 with -Xexperimental compiler option.

Example

The following function will perform n *= 2 after n += 20:

         import scala.concurrent.Future
         import com.thoughtworks.dsl.keywords.Using.scopeExit
         import com.thoughtworks.dsl.keywords.Using.unary_!
         import com.thoughtworks.dsl.macros.Reset.Default.*
         var n = 1
         def multiplicationAfterAddition = *[Future] {
           !scopeExit { () =>
             n *= 2
           }
           n += 20
         }

Therefore, the final value of n should be (1 + 20) * 2 = 42.

         multiplicationAfterAddition.map { _ =>
           n should be(42)
         }
Source
Using.scala

Givens

Givens

given given_Composed_FlatMap_OuterDomain_MappedValue[R <: AutoCloseable, Mapped <: Opaque | Trait, MappedValue, OuterDomain, BlockDomain, FinalizerDomain](using IsKeyword[Mapped, MappedValue], DslComposer[OuterDomain, MappedValue, BlockDomain], Searching[Mapped, BlockDomain, MappedValue]): Composed[FlatMap[Using[R], Mapped], OuterDomain, MappedValue]

Attributes

Source
Using.scala
given given_IsKeyword_Using_R[R]: given_IsKeyword_Using_R[R]

Attributes

Source
Using.scala

Extensions

Extensions

extension [R](r: R)(inline r: R)(using inline notKeyword: NotGiven[R <:< Keyword])
transparent inline def unary_!: R

Attributes

Source
Using.scala