bartender1382 has asked for the wisdom of the Perl Monks concerning the following question:
Swift has a wonderful feature which auto enumerates values like this:
enum ButtType : Int { case inv = 0 case tut case sup case main case stop case reg case log case set case back case new case old case up case file }</p>
In perl I am doing this for errors
use constant { SSSUCCESS => 0, SSD001 => 1, SSD002 => 2, SSFAILEDRAWDB => 3, ... };</p>
Would be nice if there was something available, like in Swift. Otherwise every time I come up with a new error, to keep them related ones together I have to insert, renumber, etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Does perl offer an auto incremental assigning of constants, like Swift?
by choroba (Cardinal) on Apr 17, 2022 at 18:15 UTC | |
by bartender1382 (Beadle) on Apr 17, 2022 at 19:00 UTC | |
|
Re: Does perl offer an auto incremental assigning of constants, like Swift?
by tybalt89 (Monsignor) on Apr 17, 2022 at 19:06 UTC | |
|
Re: Does perl offer an auto incremental assigning of constants, like Swift?
by Perlbotics (Archbishop) on Apr 18, 2022 at 19:07 UTC |