The argument passed must be of the type expected by the method. When no type is defined for a parameter, a %String argument is expected.
In following code, method DoWork2 expects to receive %Numeric
as argument and DoWork3 expects to receive %DateTime as
argument, but in both cases receive Sample.Person and will raise a
"PARAMETER error" message on runtime.
Class Sample.NightWatch
{
ClassMethod DoWork1(pObj As Sample.Person)
{
Write !,pObj.name_" "_pObj.surname
}
ClassMethod DoWork2(pObj As Sample.Person, pNmbObj As %Numeric)
{
For i=1:1:pNmbObj
{
Write !,pObj.name_" "_pObj.surname
}
}
ClassMethod DoWork3(pDate As %DateTime)
{
Write !,pDate
}
ClassMethod foo()
{
#Dim objPerson As Sample.Person = ##class(Sample.Person).%New()
Set objPerson.name = "Jon"
Set objPerson.surname = "Snow"
Set objPerson.age = 42
Do ..DoWork1(objPerson)
Do ..DoWork2(objPerson, 3) // PARAMETER error
Do ..DoWork3(objPerson) // PARAMETER error
}
}