Hacker News new | ask | show | jobs
by yetihehe 484 days 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.
1 comments

Yes, many languages use `_` as a placeholder name, and at least in Rust any name starting with `_` is considered intentionally unused.
Aside: many IRC clients would auto-append _ when registering a nick if the desired nick was already registered. Why _? Who knows.
Probably 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 `-`.