A ||= B // read as "A defaults to B"
Equivalent to:
A = A || B // "set A to A or B"
Also equivalent to:
if(!A) A = B // "if A is falsey, set A to B"
but doesn't repeat A. :)
Useful for when you want to lazy-initialize lists or other objects, especially if the variable has a really long name:
var lazy_list[]
proc
AddToLazyList(Item)
// lazy_list = lazy_list || new
lazy_list ||= new
lazy_list += Item
RemoveFromLazyList(Item)
if(lazy_list)
lazy_list -= Item
lazy_list = lazy_list.len && lazy_list // potential &&= operator? backwards tho