Open zhulinpinyu opened 6 years ago
a = ["x","y","z"] a |> Enum.reduce(%{}, fn (k,acc) -> acc |> Map.put(String.to_atom(k), "") end ) #=> %{x: "", y: "", z: ""}
简化版写法
a = ["x","y","z"] a |> Enum.reduce(%{}, &(Map.put(&2, String.to_atom(&1), ""))) #=>%{x: "", y: "", z: ""}
简化版写法