<div dir="ltr">Hello<div>I am having a problem with maps and strings as keys.</div><div>My understanding that the the two string formats "string" and <<"string">> are identical but as you can see from the transcript bellow maps does not think so.</div><div>I searched but I couldn't find any function to convert form "string" to <<"string">> or the other way around.</div><div>How can I make maps to accept both format of strings?</div><div><br></div><div>Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]<br><br>Eshell V12.0  (abort with ^G)<br>1> Key1 = "key1".<br>"key1"<br>2> <br>2> Key11 = <<"key1">>.<br><<"key1">><br>3> <br>3> string:equal(Key1, Key11).<br>true<br>4> <br>4> Map = maps:new().<br>#{}<br>5> <br>5> Map1 = maps:put("key1", {something}, Map).<br>#{"key1" => {something}}<br>6> <br>6> maps:get(Key1, Map1).<br>{something}<br>7> <br>7> maps:get(Key11, Map1).<br>** exception error: bad key: <<"key1">><br>     in function  maps:get/2<br>        called as maps:get(<<"key1">>,#{"key1" => {something}})<br>        *** argument 2: not a map<br>8> <br>8> maps:get("key1", Map1).<br>{something}<br>9> <br>9> maps:get(<<"key1">>, Map1).<br>** exception error: bad key: <<"key1">><br>     in function  maps:get/2<br>        called as maps:get(<<"key1">>,#{"key1" => {something}})<br>        *** argument 2: not a map<br>10> <br></div><div><br></div></div>