Contact Us 1-800-596-4880

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