Call different method depending on Bool without if-statement in Swift <p>Is it possible to call one or another method depending a <code>Bool</code> value? I wish to do this:</p> <pre><code>var isLocked: Bool { didSet { // This is not Swift but indicates what I'm looking for. self.activityIndicator.(isLocked ? startAnimating() : stopAnimating()) } } </code></pre> <p>I'm looking to do this using existing Swift 2 (or 3) language features; without class extensions.</p> <p>Possibly a duplicate, but couldn't find.</p>