Click or drag to resize

IsMethodClass Function

Check whether a particular method can be sent to a class.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION IsMethodClass(
	symClass AS STRING,
	symMethod AS STRING
) AS LOGIC
View Source

Parameters

symClass
Type: String
A class name as symbol.
symMethod
Type: String
The method name, specified without parentheses.

Return Value

Type: Boolean
TRUE if the specified method is defined for the class of the specified object; otherwise, FALSE.
Remarks
Examples
This example uses IsMethodClass() to check whether a class is capable of making sounds:
X#
CLASS Animal
        EXPORT sound, weight
METHOD Init(s, w) CLASS Animal
        sound := s
        weight := w
METHOD Speaks CLASS Animal
        QOut(sound)
CLASS Programmer
        EXPORT language
METHOD Init(lang) CLASS Programmer
        language := lang
METHOD Speaks CLASS Programmer
        QOut(language)
        QOut("Hello World")
        QOut(Chr(7))
Function Start()
        LOCAL dog AS Animal
        LOCAL hacker AS Programmer
        dog := Animal{"Bark Bark!", 50}
        hacker := Programmer{"VO"}
        IF IsMethodClass(#Animal, #Speaks)
                dog:Speaks()                                // Says Bark Bark
        ENDIF
        IF IsMethodClass(#Programmer, #Speaks)
                hacker:Speaks()                        // Says VO
                                                                // Says Hello World
                                                                // Rings a bell
        ENDIF
See Also