上代码: function Foo(){} //构造函数 var a = new Foo(); //实例 console.log(Foo===Foo.prototype.constructor); //true console.log(a.constructor===Foo); //true...
分类:
其他好文 时间:
2015-06-22 20:44:36
阅读次数:
123
1 -- 二维向量类 2 3 local P = { 4 x = 0, 5 y = 0 6 } 7 8 Vec2 = P 9 10 --setfenv(1, P)11 12 local function optAdd(a, b)13 local o = P:new()1...
分类:
其他好文 时间:
2015-06-22 20:28:58
阅读次数:
148
Amysql类 按照我的理解这就是框架的初始化上代码class Amysql { public $AmysqlProcess; public function Amysql() { global $Config; ini_set("magic_quot...
分类:
数据库 时间:
2015-06-22 17:50:48
阅读次数:
162
函数声明式functionfunname( 参数 ){ ...执行的代码}声明式的函数并不会马上执行,需要我们调用才会执行:funname();* 分号是用来分隔可执行JavaScript语句,由于函数声明不是一个可执行语句,所以不以分号结束。函数表达式var x = function( 参数 )....
分类:
编程语言 时间:
2015-06-22 17:40:53
阅读次数:
121
一 函数定义
func funcName(arg1:type, arg2:type, ...)->type{
// function body
return xxx
}
说明:
func 函数生命关键字,函数类型
->type 生命返回值类型
示例:
func sayHello(personName: String) -> String {
let gre...
分类:
编程语言 时间:
2015-06-22 16:26:46
阅读次数:
208
生成器是可以当作iterator使用的特殊函数。它有以下优点:1. 惰性求值;2. 在处理大的列表时不需要一次性加载全部数据,可以减小内存使用;除非特殊的原因,应该在代码中使用生成器。生成器(generator) vs 函数(function)生成器和函数的主要区别在于函数return a valu...
分类:
编程语言 时间:
2015-06-22 16:15:44
阅读次数:
111
Functions can also be called using keyword arguments of the form kwarg=value. For instance, the following function:def parrot(voltage, state='a stiff'...
分类:
其他好文 时间:
2015-06-22 14:53:31
阅读次数:
107
The default values are evaluated at the point of function definition in the defining scope, so thati = 5def f(arg=i): print(arg)i = 6f()will print ...
分类:
其他好文 时间:
2015-06-22 14:51:48
阅读次数:
98
声明式函数定义; function add(m,n) { alert(m+n); }这种方式等同于构造一个Function类的实例的方式:var add = new Function("m", "n", "alert(m+n);");
分类:
编程语言 时间:
2015-06-22 14:50:58
阅读次数:
123
如果你想交换两个变量的值:1. 整型func swapTwoInts(inout a: Int, inout b: Int) {let temporaryA = aa = bb = temporaryA}2. 字符串func swapTwoStrings(inout a: String, inout...
分类:
编程语言 时间:
2015-06-22 14:48:05
阅读次数:
153