Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[Elixir] multiple-clause-functions - replace about.md file with concept files #2375

Conversation

ErikSchierboom
Copy link
Member

In this issue we're describing an evolution of the specification of this repo.
These changes include, amongst others, replacing the contents of the after.md document with individual concept documents. There are two documents per concept:

  1. An about.md file containing the description of the concept
  2. A links.json file containing a set of useful links related to the concept.

This looks as follows in the repo:

<track>
├── concepts
│   ├── <concept>
│   │   ├── about.md
│   │   └── links.json
│   └── ...

This PR applies this change to this exercise by:

  1. Copying the existing after.md file's contents to the about.md file of each concept listed in the exercise's concepts section in the config.json file.
  2. Extract the links from the after.md file and put them into the links.json file

Before merging this PR, please check that the contents of the concept documents makes sense.
This is especially true when the exercise unlocks multiple concepts, as then the concept documents should be updated to only contain the information relevant to that concept.

Note: to make reviewing easier, the PR has been split into three separate commits. Please squash this PR upon merging.

@ErikSchierboom ErikSchierboom requested a review from a team as a code owner October 16, 2020 12:53
@angelikatyborska angelikatyborska self-assigned this Oct 18, 2020
- If none succeed, a `FunctionClauseError` is raised by the BEAM VM.
- If argument variables are unused in the body of the function, they should be prefixed with an `_` otherwise a warning is emitted by the compiler.

Note that multiple clause functions should not be confused with function overloading that you might know from other programming languages. In Elixir, functions are identified by their name and arity only, not types of arguments (since there is no static typing). The function `number/1` is considered to be a single function regardless of how many clauses it has.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this factually correct? I have a strong conviction that multiple clause functions and function overloading are different concepts, but I cannot explain well why. I couldn't find any comparisons of the two online.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know.

How I look at it:

  • In Java, function overloading means same name, different arguments(types, arity, etc), but whatever that combination of arguments it must be unique.
  • In Elixir, multiple clause functions is more of an exploded case function, where the arities can vary and the clause is selected by the arity, pattern matching, guards, and order written in the file.

:ok
end
end
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended the original text about guards with an explanation where they can be used, examples of commonly used expression, and a mention of defguard.

@angelikatyborska angelikatyborska merged commit a60333c into master Oct 19, 2020
@angelikatyborska angelikatyborska deleted the elixir-multiple-clause-functions-replace-after_md-with-concept-documents branch October 19, 2020 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants