Mnemonic for comparison functions in Scala

Scala comparison functions return boolean instead of a signed number, which is confusing for those of us deeply entrenched the C/Java family of languages, or as I call it, The Real America.

Anyway, Jason has a handy mnemonic for remembering what true means

.sort({_ < _}) produces 1 < 2 < 3

.sort({_ > _}) produces 3 > 2 > 1

Or you can remember {_ < _} as an upside-down face. It won’t tell you anything, but it’ll make you laugh.

blog comments powered by Disqus

Notes

  1. codeshal posted this