I’m working on the “Secrets” problem and running into trouble. Under Concepts there is no mention of Closures, but I believe this has to be solved using it. Any help would be appreciated.
If you look at the readme file given in the cli-provided code, it actually does mention closures once (and only very obliquely), but to answer your question, yes, you will need to use something similar to a closure for number 7 (Create a function combiner).
Anonymous functions in Elixir are closures. Yet, if you search Elixir’s official documentation, the term “closure” is not used anywhere at all. So we also don’t use it on Exercism. What you’re learning about in “Secrets” an Elixir dev would call “anonymous functions”.
A StackOverflow explanation of what’s the difference between the two in general
Thanks for the help, but I’m going to skip the problem. It boggles my mind that the official docs does not cover Closures (in relation to Elixir) at all. IMO its a huge oversight.
Can you please explain the problem you have a bit more?
I just read the exercise and I don’t see how the last assignment is different from the previous, except that you have 2 values rather than 1 that you close over.
Good news everyone! I was able to solve it. This article by Kevin Peter was a great help. My background is primarily JavaScript and he explained that closures are handled differently in Elixir.
Glad you were able to get it figured out!
Can you please elaborate on what “difference” you are talking about?
And how this is more relevant in the last part than in the others?
The exercise works with closures from the very first part, not only in the last.
If there is really such a difference that it becomes relevant for users of some other language, then there might be some room to improve the exercise. Or it’s description at least.
PS: the only significant difference I can see, is that in the last part, you actually need to call some passed in anonymous functions on your own, and the .
-call is explained in the concept description.