> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Lift Return into If

#### Sourcery refactoring id: `lift-return-into-if`

#### Description:

Lift `return` into `if`

#### Before:

```python
def f():
    if condition:
        val = 42
    else:
        val = 0
    return val
```

#### After:

```python
def f():
    if condition:
        return 42
    else:
        return 0
```

#### Explanation:

This is a quick way to streamline code slightly. Where a value is set on each
branch of an if and then immediately returned, instead return it directly from
each branch.

This has removed an unnecessary intermediate variable which we had to mentally
track.
