Re: [RFC] Enumerations, Round 2

From: Date: Wed, 30 Dec 2020 21:24:05 +0000
Subject: Re: [RFC] Enumerations, Round 2
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-112687@lists.php.net to get a copy of this message
On 30.12.2020 21:21, Larry Garfield wrote: >> enum Suit { >> case Hearts = 'H'; >> case Diamonds = 'D'; >> case Clubs = 'C'; >> case Spades = 'S'; >> } >> >> 'H' === Suit::Hearts->value; // true >> 'Hearts' === Suit::Hearts->value; // false > > That's a possibility we've been kicking around. I'm considering it, Ilija > doesn't care for it. :-) What's your argument in favor? My argument is that, from an end-user perspective, I don't really see why Unit and Scalar enums have to have different "API" at this point. I'm talking about ":string"/":int" in the enum definiton as well as ->value and ->from(). -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com

« previous php.internals (#112687) next »