Skip to content
Discussion options

You must be logged in to vote

"Closest" i've come is something like this:

class Test extends Data
{
    #[Nullable]
    public readonly bool $test1;
    #[Nullable]
    public readonly int $test2;

    public function __construct(public string $name) {
        $this->test1 = $name === 'hello world';
        $this->test2 = $name === 'hello world' ? 1234 : 5678;
    }

}

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ovp87
Comment options

You must be logged in to vote
2 replies
@ovp87
Comment options

@ejntaylor
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants