Created
March 11, 2015 16:40
-
-
Save vors/ae0d58c3737bff092309 to your computer and use it in GitHub Desktop.
Workaround that can be used in WMF 5 February Preview to emulate const.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# don't use it, it's a workaround | |
class ClassWithConst | |
{ | |
[ValidateSet(100)] | |
static [int] $CONST_FOO = 100 | |
} | |
[ClassWithConst]::CONST_FOO | |
[ClassWithConst]::CONST_FOO = 10 | |
# Output | |
100 | |
Exception setting "CONST_FOO": "The argument "10" does not belong to the set "100" specified by the ValidateSet | |
attribute. Supply an argument that is in the set and then try the command again." | |
At line:8 char:1 | |
+ [ClassWithConst]::CONST_FOO = 10 | |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException | |
+ FullyQualifiedErrorId : ExceptionWhenSetting | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment