---
title: toggle()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/bool/toggle()
---

# toggle()

Toggles the Boolean variable’s value.

## Declaration

```swift
mutating func toggle()
```

## Discussion

Discussion Use this method to toggle a Boolean value from true to false or from false to true. var bools = [true, false]

bools[0].toggle() // bools == [false, false]

## See Also

### Transforming a Boolean

- [!(_:)](swift/bool/!(_:).md)
- [||(_:_:)](swift/bool/__(_:_:).md)
- [&&(_:_:)](swift/bool/&&(_:_:).md)
