hammingDistance

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

Returns the Hamming distance between two strings.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

a

The first string.

b

The second string.

Example

This example shows how hammingDistance behaves with different strings.

Source

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

Output

3

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub