Hello.

I am "stuck" in my learning of Nim. In the attached code, I don't know how to 
get rid of the error: 'introduccionValoresEnCampos' can have side effects.

Would you be so kind as to review the code to know why I get this error in the 
function in question?

Best regards. Antonio F.S.

* * *

import std/rdstdin import std/strutils

const
    TIPO_ANIMAL : string = "Perro=1 || Gato=2: " DATOS_INCORRECTOS : string = 
"< Entrada no vĂ¡lida >" PERRO : string = "< El tipo de animal es Perro >" GATO 
: string = "< El tipo de animal es Gato >" ANIMAL_INCORRECTO : string = "< El 
tipo de animal es incorrecto"
var
    nombre: seq[string] = @[] tipo: seq[string] = @[] edad: seq[int] = @[]
func introduccionValoresEnCampos(): (seq[string], seq[string], seq[int]) =
    

var
    numTipo : int = 0 entrada : string = "" ok : bool = false
while true :
    ok = readLineFromStdin(TIPO_ANIMAL, entrada)

try:
    numTipo = parseInt(entrada)
except ValueError:
    echo DATOS_INCORRECTOS continue
case numTipo
    

of 1:
    echo PERRO nombre.add("Loki") tipo.add("Perro") edad.add(1) break
of 2:
    echo GATO nombre.add("Tim") tipo.add("Gato") edad.add(2) break
else:
    echo ANIMAL_INCORRECTO

return (nombre, tipo, edad)

proc entrarDatosAnimales*() =
    (nombre, tipo, edad) = introduccionValoresEnCampos()

Reply via email to