ace007
ace007

Reputation: 577

f(var) only works in a shell session?

I'm needing to reset some variables in a loop in order to assign the new values (like finding the index of a substring) i cannot reuse the same var so i must unset it and as far as i know the f(var) only works in a shell?

so is there no way to do this in a script?

Upvotes: 1

Views: 162

Answers (1)

chops
chops

Reputation: 2612

f() is a shell-only command.

Erlang as a language uses immutable variables, and as such does not allow the resetting of variables within the code itself. The recommendation is to get comfortable with recursion, list comprehensions, mapping, or folding in order to accomplish "loops" which don't exist in the procedural sense in Erlang.

If you must rely on variable state, the closest thing you get to mutable variables is the process dictionary: get/1 and put/2. These are generally discouraged unless there is a good reason for using them.

Upvotes: 8

Related Questions