Skip to main content

W0072 - Use binary:encode_hex/2 with case argument

Warning

hex(X) ->
string:lowercase(binary:encode_hex(X)).
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 warning: W0072: Use `binary:encode_hex/2` with a case argument instead of wrapping with `string:lowercase/1`.

Explanation

The warning indicates that you are wrapping binary:encode_hex/1 with string:lowercase/1 to produce lowercase hex output. Since OTP 26, binary:encode_hex/2 accepts a case argument directly, making this wrapper unnecessary.

Fix

Replace the pattern with binary:encode_hex/2:

hex(X) ->
binary:encode_hex(X, lowercase).