你遇到过的源代码中最好的注释是什么?


当前回答

下面的代码是在Python模拟教程中看到的。

# This is my rifle.
def rifle(type='hunting'):
    print('This is my (%s) rifle.' % type)

# This is my gun.
def gun(type='hand'):
    print('This is my (%s) gun.' % type)

# This is for fighting.
def fighting(type='illegal'):
    print('This is for (%s) fighting.' % type)

# This is for fun.
def fun(type='gaming'):
    print('This is for (%s) fun.' % type)

作者一定是《恶搞之家》的粉丝。^ _ ^

其他回答

不是注释,而是属性

[ThereBeDragons]

还有一个是我在IHttpHandler的实现中看到的

//What is this?
public bool IsReusable
{
    get{return false;}
}
// This part is more difficult

在方法的顶部。

大概有5行。

并不难。

这是唯一的评论。

在整个应用程序中。

下面是一个必须声明的局部变量,只是为了将一个常量传递给库函数:

// This only exists because Scott doesn't know how to use const correctly
// The ratio of a circle's circumference to its diameter.  Remember to change
// this to 3.0 if you move to a site in Indiana.

#define Pi                                      3.1415927
// If this comment is removed the program will blow up