- (Hyphen-Minus) is ASCII code point 45 (0x2D), Unicode U+002D, and a printable punctuation character. It joins compound words ("well-known"), separates syllables at line breaks, and doubles as the minus sign in everyday arithmetic — three roles crammed into one glyph because early character sets couldn't afford the luxury of separate symbols. In programming, - subtracts, negates, and decorates. It's the subtraction and unary negation operator everywhere, the arrow -> for pointer member access in C and return type annotation in Python, and the flag prefix for command-line options (ls -la). YAML uses it to introduce list items, and Markdown turns a line of --- into a horizontal rule. The character's most insidious programming trap involves CLI argument parsing: a filename beginning with a hyphen, like -report.txt, gets interpreted as an option flag instead of a file operand, and rm -report.txt throws an "invalid option" error rather than deleting anything. The conventional fix — rm -- -report.txt — uses the double-hyphen sentinel to say "everything after here is a filename, not a flag." ASCII conflated hyphen and minus into a single code point because teletype machines had limited character budgets. Proper typography distinguishes at least three marks: hyphen, en dash, and minus sign. UTF-8 encodes it as a single byte 0x2D. Unicode classifies it as Pd (Punctuation, Dash) with the name HYPHEN-MINUS. The true minus − (U+2212) and en dash – (U+2013) are the characters typographers wish everyone used instead, but decades of habit keep 0x2D firmly entrenched.
int neg = -45; // '-' makes a number negativeint diff = 10 - 3; // subtraction operatorchar opt = '-'; // ASCII 45 literal in code
The hyphen-minus (ASCII 45) is on your keyboard. The en-dash (–, U+2013) is for ranges (pages 1–10). The em-dash (—, U+2014) is for parenthetical statements. Only the hyphen-minus exists in ASCII — the others are Unicode. Word processors auto-correct -- to —, but code editors don't.
ASCII only has one character (code 45) for both purposes. The typographic minus (−, U+2212) is actually wider and vertically centered differently than the hyphen-minus. In code, there's no distinction — the hyphen-minus handles subtraction, negative numbers, and CLI flags alike.
Double dash signals 'end of options' — everything after it is treated as arguments, not flags. This prevents a filename like '-rf' from being interpreted as flags: rm -- -rf safely deletes the file named '-rf'. It's essential for handling user-provided filenames securely.
CSS identifiers follow specific rules: they can start with a letter, underscore, or hyphen, but a hyphen can't be followed by a digit (-.5class is invalid). This prevents ambiguity with negative numbers in property values. Use a letter after the hyphen: .my-1col works.