To be consistent with the practice project, it should be .one. So I updated the instructions to use .one also. As it was written, you were right, it should have been .get. Hopefully this helps clear up the confusion! Thanks for reporting the issue.
Just remember you can stick IO.inspect anywhere with a pipe. In this example, when I’m playing around and trying to figure out what the output of the steps are, I can write an IO.inspect on each line of the with. It’s not as clean as it can be in a pipeline, but it works!
with {:ok, width} <- Map.fetch(data, :width) |> IO.inspect(label: "WIDTH"),
{:ok, height} <- Map.fetch(data, :height) |> IO.inspect(label: "HEIGHT") do
{:ok, width * height}
end
Doing it like this still outputs the result before the pattern match on the left, so you’ll see any unexpected output that way.
Should it be Users.get(1) instead of Users.one(1) and the same for Customers in the paragraph “Telling the Difference” code example ?
Hey Maksym,
To be consistent with the practice project, it should be
.one
. So I updated the instructions to use.one
also. As it was written, you were right, it should have been.get
. Hopefully this helps clear up the confusion! Thanks for reporting the issue.I have a question. Where on “with… do .. end” it’s better put IO.inspect in to investigate what the function call returns?!
Great question!
Just remember you can stick
IO.inspect
anywhere with a pipe. In this example, when I’m playing around and trying to figure out what the output of the steps are, I can write anIO.inspect
on each line of thewith
. It’s not as clean as it can be in a pipeline, but it works!Doing it like this still outputs the result before the pattern match on the left, so you’ll see any unexpected output that way.