W0030 - maps:put/3 usage rather than dedicated syntax
Warning
main(K, V, Map) ->
maps:put(K, V, Map).
%% ^^^^^^^^^^^^^^^^^^^💡 information: Consider using map syntax rather than a function call.
Explanation
The warning message indicates that a key-value is being inserted into a map
using the maps:put/3 function call rather than the dedicated syntax.
Whilst this will correctly and unconditionally insert the key-value into the map, it is not considered idiomatic, and may be less efficient than using the map update syntax directly.
If the keys are constants known at compile-time, using the map update syntax
with the => operator is more efficient than multiple calls to maps:put/3,
especially for small maps. This implies than using the => operator should
make future additions to the code both more performant and more clear.
To fix the issue, use the built-in Map#{Key => Value} syntax to insert the
Key and Value into the Map:
main(K, V, Map) ->
Map#{K => V}.
Note: Use the := operator instead, for performance and code clarity, if
the key should already exist in the Map.