exercism/elixir

Captain's Log instructions should nudge the student towards the erlang call requirement.

zorn opened this issue · 8 comments

zorn commented

## 4. Format the stardate
In the captain's log, stardates are usually rounded to a single decimal place.
Implement the `format_stardate/1` function that will take a floating point number and return a string with the number rounded to a single decimal place.
```elixir
CaptainsLog.format_stardate(41458.15721310934)
# => "41458.2"
```

I solved this early on with the following but then was dumbfounded why the test would be specifically looking for an ArgumentError. When I attempted to add guards I got FunctionClauseError which of course did not match.

  def format_stardate(stardate) do
    Float.round(stardate, 1) |> Float.to_string()
  end

Suggestion

I suggest we add a line to the instructions hinting that solving this using an erlang call is a requirement.

Hi @zorn, frightfully sorry for the long response time.
We already have hints in place that suggest to use an Erlang function, and also this is an exercise about Erlang interop, so I don't know if we need to change the instructions. What do you think about it?

zorn commented

I'll be transparent and share I work on the exercises in a local editor environment, and it never even occurred to me to look for a file called HINTS.md. I always just opened the README file and work from there.

That said, I find misalignment in that the tests for task four are checking "does not accept integers" and asserting that behavior by looking for ArgumentError. There is nothing in the task instructions to suggest this as a specification.

If you removed the HINTS file, assuming it is optional content, and just read the tasks and tests I feel it was confusing, at least for me. 🤷‍♂️

Right, I stumbled onto your videos yesterday, I think it would have been useful to know about the hints for the AST one ;)
Great job on the videos BTW!

The concept exercises are optimized for the online editor, and the hints are part of that, but I see where you're coming from.
OK, let me look into this and come back to you.

zorn commented

Sounds good. Obviously, my feedback is one signal so take it into consideration with the others. Good luck!

Hi @zorn, I've thought about this, and I don't see anything wrong with being a more explicit in the main instructions. We could probably simply add a line

Implement the `format_stardate/1` function that will take a floating point number and return a string with the number rounded to a single decimal place. 
The implementation should use an Erlang function.

What do you think? Would you like to help implementing that change?

zorn commented

Sure. I'll make a PR over the weekend.

Awesome. We should probably do the same for task 3.

zorn commented

Awesome. We should probably do the same for task 3.

The thing is, the tests for task 3 do not currently validate a specific Erlang implementation. What threw me originally was that the tests for task 4 were looking for assert_raise ArgumentError