On Wed, Dec 30, 2020, at 2:43 AM, Markus Fischer wrote:
> Hi,
> 
> On 28.12.20 21:21, Larry Garfield wrote:
> > The full RFC is here, and I recommend reading it again in full given how 
> > much was updated.
> > 
> > https://wiki.php.net/rfc/enumerations
> 
> I tried to answer the following question but failed to do so:
> 
> What is the scalar value for a ScalarEnum if none is explicitly defined?
> 
> The RFC makes this example:
>  > enum Suit: string implements Colorful {
>  >    case Hearts = 'H';
>  >    case Diamonds = 'D';
> …
>  > 'D' == Suit::Diamonds->value; // true
> 
> 
> What in this case?
> 
>  > enum Suit: string {
>  >    case Hearts;
>  >    case Diamonds;
> …
> 
> What is the outcome of `Suit::Diamonds->value` ?

A parse error on the declaration; if it's a scalar enum, explicit values are 
required for all cases.

--Larry Garfield

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to