The following code is supposed to accumulate the result of changing the strings in sslCmd but clearly doesn’t work. I am not sure how it should recurse or iterate. Any ideas?
Do you assign or return the return value of got snippet of are you relying on mutation of sslCmd? If the later, remember that there is no such thing in elixir
The assignment to sslCmd does not belong in the reduce function. It doesn’t change on account immutability. When assigned to the outcome of the Enum it works.
I have the Enum.reduce method working. This time I want to make make recursive calls over the list with this replace_string function. Is it all okay or are there some cases I have missed?
def replace_string(subject, []), do: subject
def replace_string(subject, [head | tail]) do
replace_string(String.replace(subject, "{{#{head.key}}}", head.value),tail)
end