Another test of closure.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
a4b5db4005
commit
ee7b1e56ae
|
@ -0,0 +1,24 @@
|
|||
class Dog {
|
||||
public string $name;
|
||||
public string $color;
|
||||
|
||||
public void __construct(string $name, string $color) {
|
||||
$this->name = $name;
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
public callback greet(string $greeting) {
|
||||
return void() using ($greeting) {
|
||||
print("$greeting, I am a {$this->color} dog named {$this->name}\n");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Program {
|
||||
|
||||
void main() {
|
||||
object $dog = new Dog('Alex', 'red');
|
||||
callback $c = $dog->greet('Hello');
|
||||
$c();
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Hello, I am a red dog named Alex
|
Loading…
Reference in New Issue