- Fat comma
Fat comma is a programming term primarily associated with the
Perl and Rubyprogramming language s, though others doubtless also employ the token. It refers to an operator, indicated as "=>", that can be used as a substitute for the comma operator and is an example of good idiomatic Perl when used to bind key-value pairs in a hash.Cite book|last=Conway|first=Damian|authorlink=Damian Conway|editor=Allison Randal and Tatiana Appandi|title=Perl Best Practices |origyear=2005|publisher=O'Reilly Media, Inc.|isbn=0-596-00173-8|chapter=4: Values and Expressions|pages=66|quote=Whenever you are creating a list of key/value or name/value pairs, use the "fat comma" (=>) to connect the keys to their corresponding values.]Subtleties
When working under strict mode (a solid programming practice that forces the developer to adhere to the highest standards of consistency, typing and declaration available to the language's
compiler ), the fat comma has one advantage over its comma (',') analogue: it forces the word to its left to be interpreted as a string [http://perldoc.perl.org/perlop.html#Comma-Operator-comma-operator%2c-comma-%2c] .Thus, wherewould produce a run-time error (barewords are not allowed under strict), the following use of the fat commawould be legal and idiomatic, because the token
converted_to_string
would be converted to the string literal "converted_to_string" which is a legal argument in a hash key assignment.The result is easier-to-read code, with a stronger emphasis on the name-value pairing ofassociative array s.References
Wikimedia Foundation. 2010.