Re: Let's discuss enums!

From: Date: Fri, 18 Sep 2015 08:42:57 +0000
Subject: Re: Let's discuss enums!
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-88314@lists.php.net to get a copy of this message
On 18 September 2015 01:15:43 BST, Bob Weinand <bobwei9@hotmail.com> wrote: >The reason it is not an associative array is that the names are not >important. ... >You never should *rely* on the ordinal value of the enum for anything. I feel like I'm missing something here. In my mind, the only absolute universal about all enum implementations is that you refer to values by constant names - e.g. Weekdays::SUNDAY. The name 'SUNDAY' is as fundamental and unchanging as the name 'Weekdays'. We rely on names to reference classes and functions all the time, and to serialize properties of an object; so what is it about enums that makes having an integer accessible so important? I note that Java does supply an ordinal(), but the docs say you should basically never use it. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#88314) next »