Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the meaning of double underscore ($_.value__)?

Tags:

powershell

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.

like image 703
Nicola Cossu Avatar asked Apr 26 '11 14:04

Nicola Cossu


People also ask

What does double underscore mean?

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.

What's the meaning of single and double underscores in Python?

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.

What is double underscore methods in Python?

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.

What does double underscore mean in C++?

According to the C++ Standard, identifiers starting with one underscore are reserved for libraries. Identifiers starting with two underscores are reserved for compiler vendors.


1 Answers

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?

like image 195
Roman Kuzmin Avatar answered Sep 23 '22 10:09

Roman Kuzmin