Today on powershell.com
http://powershell.com/cs/blogs/tips/archive/2011/04/26/dump-enumerations.aspx
I've found this tip
function Get-Enum($name){
[Enum]::GetValues($name) | Select-Object @{n="Name";e={$_}},@{n="Value";e={$_.value__}} |
format-table -autosize
}
Can someone explain me what's the meaning of $_.value__
?
Thanks.
Double underscores are used for fully private variables. According to Python documentation − If your class is intended to be subclassed, and you have attributes that you do not want subclasses to use, consider naming them with double leading underscores and no trailing underscores.
Single Trailing Underscore( var_ ): Used by convention to avoid naming conflicts with Python keywords. Double Leading Underscore( __var ): Triggers name mangling when used in a class context. Enforced by the Python interpreter.
A double underscore prefix causes the Python interpreter to rewrite the attribute name in order to avoid naming conflicts in subclasses. This is also called name mangling—the interpreter changes the name of the variable in a way that makes it harder to create collisions when the class is extended later.
According to the C++ Standard, identifiers starting with one underscore are reserved for libraries. Identifiers starting with two underscores are reserved for compiler vendors.
I would say this is kind of a hacky way to get the underling value of a enum. Here is the related question and answer: What is the purpose of the public "value__" field that I can see in Reflector against my enum?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With