HasBase

指定された値が指定されたベースオブジェクトから派生したものである場合、0 以外の数値を返します。

HasBase := HasBase(Value, BaseObj)

パラメータ

任意の値、任意の型。

BaseObj

型:Object

テストするベースオブジェクトの候補です。

戻り値

型:整数(ブーリアン)

This function returns 1 (true) if BaseObj is in Value's chain of base objects, otherwise 0 (false).

備考

次のコードは、この機能とほぼ同等です:

MyHasBase(Value, BaseObj) {
    b := Value
    while b := ObjGetBase(b)
        if b = BaseObj
            return true
    return false
}

For example, HasBase(Obj, Array.Prototype) is true if Obj is an instance of Array or any derived class. This the same check performed by Obj is Array; however, instances can be based on other instances, whereas is requires a Class.

HasBaseは、オブジェクトとプリミティブな値の両方を受け入れます。例えば、HasBase(1, 0.base)は真を返します。

Objects, Obj.Base, ObjGetBase, HasMethod, HasProp

本機能の使用方法を説明します。

thebase := {key:"value"}
derived := {base:thebase}
MsgBox HasBase(thebase, derived) ; 0
MsgBox HasBase(derived, thebase) ; 1