3 ms·
I nice factoid: in Erlang, `_` if functional. It means "I don't care about this variable". When pattern matching you can put `_` to not bind value in function o
by yetihehe 2y ago
I nice factoid: in Erlang, `_` if functional. It means "I don't care about this variable". When pattern matching you can put `_` to not bind value in function or pattern to anything or prepend a variable with `_` to tell compiler that you won't be using it, but it's there for "documentation" purposes. For example `[A|_]=List` will extract first element of list into A and ignore rest of list. Underscore has some other uses too.
- Sharlin 2y agoYes, many languages use `_` as a placeholder name, and at least in Rust any name starting with `_` is considered intentionally unused.
- hunter2_ 2y agoAside: many IRC clients would auto-append _ when registering a nick if the desired nick was already registered. Why _? Who knows.
- Sharlin 2y agoProbably because it has no specific meaning and being almost whitespace is the easiest to mentally ignore out of the set of valid nickname characters. `-` is another candidate but a programmer used to C-like languages will likely intuitively pick `_` just because it’s valid in identifiers unlike `-`.