Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
45
Task/Delegates/FreeBASIC/delegates.basic
Normal file
45
Task/Delegates/FreeBASIC/delegates.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue