[Elixir] multiple-clause-functions - replace about.md file with concept files #2375
[Elixir] multiple-clause-functions - replace about.md file with concept files #2375
Conversation
…le from after.md file
…file from after.md file
- 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
``` |
There was a problem hiding this comment.
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
.
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:about.md
file containing the description of the conceptlinks.json
file containing a set of useful links related to the concept.This looks as follows in the repo:
This PR applies this change to this exercise by:
after.md
file's contents to theabout.md
file of each concept listed in the exercise'sconcepts
section in theconfig.json
file.after.md
file and put them into thelinks.json
fileBefore 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.