Re: final keyword
| From: | Sebastian Schneider | Date: | Wed, 13 Feb 2008 09:59:14 +0000 |
| Subject: | Re: final keyword | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35437@lists.php.net to get a copy of this message | ||
actually, the method SHOULD NOT be named get_status but getStatus :P
(sorry for that, but couldn't help myself - feel free to get even ;) )
By the way, when declared final the value couldn't be changed, anyways -
however it MUST be read-only.
But using a method like the one you suggested is just working around a common code pattern which is available in other wide-spread languages like Java, and others.
So finally, const should work with arrays or final with all class members including attributes.
Cheers
Sebastian schrieb:
Plus as it is a constant it's value cannot be changed in the context of the object. However you could implement a method for this, e.g. get_status(); which then returns an array. But the final keyword would be more comfortable.... "Sebastian Schneider" <ses@m7-evolution.com> schrieb im Newsbeitrag news:47B1AFB5.5070505@m7-evolution.com...Sebastian Bergmann schrieb:Sebastian Schneider schrieb:But doesn't work with arrays, e.g. public class Result {public static final $bar = "foobar's world";We have the const keyword for that.const DECISION_PERMIT = 0; const DECISION_DENY = 1; const DECISION_INDETERMINATE = 2; const DECISION_NOT_APPLICABLE = 3;const DECISIONS = array( 'Permit', 'Deny', 'Indeterminate', NotApplicable' );//.... } thus you need to work around with private/protected statics, which seems to be incoherent to me.