Edit params after they have arrived

Hey is it possible to edit params in any way?

challenge_params["main"] = true

I am thinking something like this, but this just gives an error that says:

cannot invoke remote function Access.get/2 inside match

Data is immutable in Elixir so you cannot modify a datastructure like that. You can use Map.put to update a map like this:

params = Map.put(params, "main", true)

That will give you a new copy of the map with the new value.

3 Likes