Box

abstract class Box[V] extends (V, V) => V

A Box is a way to combine two values into a new one. It is a specialization of the functional type (V,V) => V, where the first parameter is the old value of an unknown and the second parameter is the new contribution. Both widenings and narrowings are examples of boxes. Boxes are mutable, i.e., the apply method may give different results for the same input when called multiple times.

Another function of boxes is to be blueprints for building other equivalent boxes. Each box has a copy method which should produce a functionally equivalent copy of this. The copy method should try to minimize object duplication.

Type parameters:
V

the type of the values to combine.

Companion:
object
trait (V, V) => V
class Object
trait Matchable
class Any
class ImmutableBox[V]

Value members

Abstract methods

def copy: Box[V]

Returns a copy of this box. An immutable box may just returns itself, but a mutable one should produce a distinct a copy of itself.

Returns a copy of this box. An immutable box may just returns itself, but a mutable one should produce a distinct a copy of itself.

def isIdempotent: Boolean

It returns true if the box is guaranteed to be idempotent, i.e., if x box y = (x box y) box y. This may be used for optimization purposes.

It returns true if the box is guaranteed to be idempotent, i.e., if x box y = (x box y) box y. This may be used for optimization purposes.

def isImmutable: Boolean

It returns true if this box is immutable, i.e., if the apply method does not change its behaviour over time.

It returns true if this box is immutable, i.e., if the apply method does not change its behaviour over time.

def isRight: Boolean

It returns true if this is guaranteed to be the right box (i.e., the one which always returns the second component). This may be used for optimization purposes.

It returns true if this is guaranteed to be the right box (i.e., the one which always returns the second component). This may be used for optimization purposes.

Concrete methods

def delayed(delay: Int): Box[V]

Returns a delayed version of the box. It is equivalent to applying cascade to the right box.

Returns a delayed version of the box. It is equivalent to applying cascade to the right box.

Inherited methods

def apply(v1: V, v2: V): V
Inherited from:
Function2
@unspecialized
def curried: V => V => V
Inherited from:
Function2
override def toString(): String
Definition Classes
Function2 -> Any
Inherited from:
Function2
@unspecialized
def tupled: (V, V) => V
Inherited from:
Function2