---
title: take()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/optional/take()
---

# take()

Takes the wrapped value being stored in this instance and returns it while also setting the instance to nil. If there is no value being stored in this instance, this returns nil instead.

## Declaration

```swift
mutating func take() -> Optional<Wrapped>
```

## Return Value

Return Value The wrapped value being stored in this instance. If this instance is nil, returns nil.

## Discussion

Discussion var numberOfShoes: Int? = 34

if let numberOfShoes = numberOfShoes.take() {   print(numberOfShoes)   // Prints "34" }

print(numberOfShoes) // Prints "nil"
