Can

com.phasmidsoftware.number.algebra.core.Can
sealed trait Can[T <: Structure]

Trait Can represents an abstraction where a type T which extends Structure can cast an instance to itself. It is the base trait for all other traits that extend Can.

This trait facilitates type-safe casting of instances to a specific subtype of Structure. The trait no longer extends Structure, removing the circular dependency while maintaining type safety through ClassTag-based runtime verification.

Type parameters

T

the type parameter which must be a subtype of Structure

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait CanAdd[T, U]
class Real
class WholeNumber
class Angle
class Exponential
trait CanMultiply[T, U]
trait CanNegate[T]
Show all

Members list

Value members

Concrete methods

def asT: T

Casts the current instance to the type parameter T of the enclosing Can trait.

Casts the current instance to the type parameter T of the enclosing Can trait.

This method performs a type-safe cast using the ClassTag to verify at runtime that the cast is valid. If the current instance cannot be cast to type T, an AlgebraException is thrown.

Attributes

Returns

the current instance as an instance of type T

Throws
AlgebraException

if the cast is invalid