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

# AL0004 - Use pattern matching when comparing Span with constants

> Use pattern matching instead of equality operators for Span constant comparisons

Source: [AL0004ToAL0005SpanComparisonAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/AL0004ToAL0005SpanComparisonAnalyzer.cs)

## Description

When comparing Span and a constant, use pattern matching instead of equality operators, unless you want to compare addresses.

## Bad Code

```csharp theme={null}
if (span == "hello")
```

## Good Code

```csharp theme={null}
if (span is "hello")
```

## Properties

* **Category**: Usage
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: True

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0004.severity = warning
```
