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

# 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
```
