---
schema_version: "1"
id: 740ec22814f1e7c95e11ecc0124dd79f66a94dee011860544a5c7c0b2f537d7e
title: hammingDistance
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-strings-functions-hammingdistance.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-strings-functions-hammingdistance
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5b449223eba17655a168131f3e2306aef59b32942846b8c14ace4bcedf859eae
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# hammingDistance

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## hammingDistance(a: String, b: String): Number | Null

Returns the Hamming distance between two strings.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>a</code></p></td><td><p>The first string.</p></td></tr><tr><td><p><code>b</code></p></td><td><p>The second string.</p></td></tr></tbody></table>

### Example

This example shows how `hammingDistance` behaves with different strings.

#### Source

```DataWeave
%dw 2.0
import hammingDistance from dw::core::Strings
output application/json
---
"holu" hammingDistance "chau"
```

#### Output

```Json
3
```
