AnyFunctions1 S

any.spad line 125 [edit on github]

AnyFunctions1 implements several utility functions for working with Any. These functions are used to go back and forth between objects of Any and objects of other types.

coerce: S -> Any

coerce(s) creates an object of Any from the object s of type S.

retract: Any -> S

retract(a) tries to convert a into an object of type S. If possible, it returns the object. Error: if no such retraction is possible.

retractable?: Any -> Boolean

retractable?(a) tests if a can be converted into an object of type S.

retractIfCan: Any -> Union(S, failed)

retractIfCan(a) tries change a into an object of type S. If it can, then such an object is returned. Otherwise, “failed” is returned.