Skip to content
richardszalay edited this page May 20, 2011 · 6 revisions

Enforces that values emitted from a sequence are of a specified type

function cast(valueClass : Class) : IObservable.<valueClass>

Remarks

This operator is useful when using an operator that requires all input sequences to be of the same valueClass. In these cases, cast can be used to cast the sequences to a common base class. It can also be used to cast between number classes (Boolean, int, uint, Number) since implicit conversions between those classes are supported by the runtime.

The returned sequence completes when the source sequence completes.

The returned sequence raises an error if the source sequence raises an error or if a non-null value cannot be cast to valueClass

Return Value

IObservable.<valueClass>

Examples

Observable.range(1, 3).cast(Number)
    .subscribe(
        function(value : Number) : void { trace(value); },
        function():void { trace("Completed"); }
    );

    // Trace output is:
    // 1
    // 2
    // 3
    // Completed
Clone this wiki locally