Toot

Written by Tim Düsterhus on 2024-10-28 at 10:40

Really looking forward to be able to use property hooks with #php84.

use function array_pop as p;

final class Calculator {

private $s = [];

public float $v { get => end($this->s); set { $this->s[] = $value; } }

public null $add { get { $s = &$this->s; $s[] = p($s) + p($s); return null; } }

public null $mul { get { $s = &$this->s; $s[] = p($s) * p($s); return null; } }

}

$c = new Calculator();

$c->v = 2;

$c->v = 20;

$c->v = 2;

$c->mul;

$c->add;

var_dump($c->v);

[#]PHP

=> More informations about this toot | View the thread | More toots from timwolla@phpc.social

Mentions

Tags

=> View php84 tag | View php tag

Proxy Information
Original URL
gemini://mastogem.picasoft.net/toot/113384620852242191
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
219.696103 milliseconds
Gemini-to-HTML Time
0.501811 milliseconds

This content has been proxied by September (3851b).