Comparison of Programming Languages (object-oriented Programming) - Type Manipulation

Type Manipulation

Get object type Is instance of (includes subtypes) Upcasting Downcasting
Runtime check No check
ABAP Objects = ?=
C++ (STL) typeid(x) dynamic_cast<type *>(&x) != NULL dynamic_cast<type*>(ptr) (type*) ptr or
static_cast<type*>(ptr)
C# x.GetType x is type (type) x or x as type
D typeid(x) cast(type) x
Delphi x is type x as type
Java x.getClass x instanceof class (type) x
Objective-C (Cocoa) ] (type*) x
JavaScript x.constructor x instanceof class
Visual Basic .NET x.GetType TypeOf x Is type CType(x, type) or TryCast(x, type)
Eiffel x.generating_type attached {TYPE} x attached {TYPE} x as down_x
Python type(x) isinstance(x, type)
PHP get_class(x) x instanceof class
Perl ref(x) x->isa("class")
Perl 6 x.WHAT x.isa(class) type(x) or
x.type
Ruby x.class x.instance_of?(type) or
x.kind_of?(type)
Smalltalk x class x isKindOf: class
Windows PowerShell x.GetType x -is x or x -as
OCaml (x :> type)
F# x.GetType x :? type (x :?> type)

Read more about this topic:  Comparison Of Programming Languages (object-oriented Programming)

Famous quotes containing the words type and/or manipulation:

    The more characteristic American hero in the earlier day, and the more beloved type at all times, was not the hustler but the whittler.
    Mark Sullivan (1874–1952)

    When we say “science” we can either mean any manipulation of the inventive and organizing power of the human intellect: or we can mean such an extremely different thing as the religion of science the vulgarized derivative from this pure activity manipulated by a sort of priestcraft into a great religious and political weapon.
    Wyndham Lewis (1882–1957)