4 ms·
not sure how i made it through my entire CS degree without learning this term. either that or i just don't remember it. anyways, thank you! this is really usefu
by brintnc 7y ago
not sure how i made it through my entire CS degree without learning this term. either that or i just don't remember it. anyways, thank you! this is really useful even outside of Elixir.
- quaunaut 7y agoI've honestly never heard anyone who isn't an Elixir programmer use it. I wouldn't worry about not having heard it before.
- grzm 7y agoIt's much more common than just Elixir programmers. It's a common concept in computer science, particularly in functional programming or languages which permit function overloading on arguments. https://en.wikipedia.org/wiki/Arity https://en.wikipedia.org/wiki/Arity Edit to add: I've heard and used arity for at least 10 years, in particular in the Clojure community. I've heard of Elixir and understand it shares some common ideas with Clojure and Ruby, but never been a part of its community.
- hopia 7y agoIn functional programming classes at the uni you probably wouldn't hear this because if they teach Haskell which I assume most do, every function always takes just one argument. That's because functions are curried by default. I personally haven't really heard this mentioned anywhere outside of the Erlang/Elixir sphere.
- cthalupa 7y agoThis thread really surprised me - I learned about arity when learning about ternary operators, which are pretty universal - you can find ?: in all sorts of languages. I think I was learning about C when I first got a detailed explanation on the subject.
- pmarreck 7y agoEven if every function is curried by default (and "currying" is yet another concept that may be alien to users of some languages), it is probably still useful to know with what number of arguments a function can evaluate to a value that is not just another function
- pmarreck 7y agoI learned about it in the Ruby world. Also, interestingly, it was available from Javascript 1.2 to 1.4: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arity https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... I think it's a useful name for a useful concept, not sure why they'd take it out, "Function.prototype.length" is a much poorer replacement semantically (but hey, Javascript isn't known for its correctness or well-thought-out design...)
- Maultasche 7y agoI had never heard of "arity" either until I started reading about functional programming concepts. It seems to be used a lot within the functional programming world, but not so much outside of that.