I am an absolute beginner in Elixir and I tried toying around with recursion by making a function like this:
def player_choice() do
choice = IO.gets("Choose rock, paper or scissors: ") |> String.trim()
unless String.downcase(choice) in ["rock", "paper", "scissors"] do
IO.puts("\nPlease insert a valid move")
choice = player_choice()
end
choice
end
So if someone inputs a value thats not expected the function should continue asking for an input. But if the first input is something unexpected like "no", and the next input is "rock" the function will return "no". Why does this happen, shouldn't "choice" be the reassigned value?