1
votes

New to Elixir, I'm trying to write a simple game that will have a readFrom/1 function that reads inputs and plays the game accordingly, and then a print/1 function that will print that game.

Since they will be called through the iex one after the other, how can I make the print/1 function print the result from readFrom/1? In any other language I would just save the values I need in variables and just get them after with the print/1 function.

I have to do it this way due to requirements, and I can't find anything that will help me figure this out.

Thanks!

2

2 Answers

2
votes

You could use a pipe:

iex> args |> readFrom() |> print()
0
votes

You can run your script from iex by simply adding the script name on the iex command line, like so:

$iex myscript.exs