Definition

Implemented as a class:

class FIFO(*array) {
    method pop {
        array.is_empty && die "underflow"
        array.shift
    }
    method push(*items) {
        array += items
        self
    }
    method empty {
        array.len == 0
    }
}

Last updated