Showing posts with label operator. Show all posts
Showing posts with label operator. Show all posts

July 15, 2008

?~

Scala loves it some overloaded operators.

When working with the highly useful Can class from net.liftweb.util, the ?~ operator is equivalent to asking "is this Can empty?", but has the added bonus of returning a Failure object if it is.

This makes for pleasantly terse expressions that handle failure cases inline.

July 9, 2008

:: == cons

The ::operator is more or less equivalent to cons in Lisp, ML, and similar languages. When you're pattern matching, it extracts. When you're declaring or assigning variables (particularly Lists), it concatenates.