---
agentTools:
  projectIndex: https://operations.readme.io/llms.txt
---

# Gated Operation

`GatedOperation` is similar to `ComposedOperation` except that it also accepts a `() -> Bool` block. If the block evaluates true, the composed operation will be executed.

This is useful to optionally execute an operation.

[block:code]
{
  "codes": [
    {
      "code": "let operation = GatedOperation(anotherOperation) { return trueOrFalse() }\nqueue.addOperation(operation)",
      "language": "swift"
    }
  ]
}
[/block]