46 lines
879 B
Plaintext
46 lines
879 B
Plaintext
Type Objeto
|
|
operation As Function() As String
|
|
other As String
|
|
End Type
|
|
|
|
Function xthing() As String
|
|
Return "default implementation"
|
|
End Function
|
|
|
|
Function newX() As Objeto
|
|
Dim As Objeto o
|
|
o.operation = @xthing
|
|
Return o
|
|
End Function
|
|
|
|
Function newY() As Objeto
|
|
Dim As Objeto o = newX()
|
|
o.other = "something else"
|
|
o.operation = 0 ' remove delegate
|
|
Return o
|
|
End Function
|
|
|
|
Function zthing() As String
|
|
Return "delegate implementation"
|
|
End Function
|
|
|
|
Function newZ() As Objeto
|
|
Dim As Objeto o = newX()
|
|
o.operation = @zthing ' replace delegate
|
|
Return o
|
|
End Function
|
|
|
|
Function operation(o As Objeto) As String
|
|
Return Iif(o.operation <> 0, o.operation(), "no implementation")
|
|
End Function
|
|
|
|
Dim As Objeto x = newX()
|
|
Dim As Objeto y = newY()
|
|
Dim As Objeto z = newZ()
|
|
|
|
Print operation(x)
|
|
Print operation(y)
|
|
Print operation(z)
|
|
|
|
Sleep
|