---
title: "init(forVariable:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsexpression/init(forvariable:)"
---

# init(forVariable:)

Creates an expression that extracts a value from the variable bindings dictionary for a specified key.

## Declaration

```swift
init(forVariable string: String)
```

## Parameters

- `string`: The key for the variable to extract from the variable bindings dictionary.

## Return Value

Return Value A new expression that extracts from the variable bindings dictionary the value for the key string.

## See Also

### Creating an Expression for a Value

- [init(forConstantValue:)](foundation/nsexpression/init(forconstantvalue:).md)
- [expressionForEvaluatedObject()](foundation/nsexpression/expressionforevaluatedobject().md)
- [init(forKeyPath:)](foundation/nsexpression/init(forkeypath:)-1aqf5.md)
- [init(forKeyPath:)](foundation/nsexpression/init(forkeypath:)-98by.md)
- [expressionForAnyKey()](foundation/nsexpression/expressionforanykey().md)
