5 函数与闭包
使用 func 声明一个函数。调用函数使用他的名字加上小括号中的参数列表。使用 -> 分隔参数的名字和返回值类型。
func greet(name: String, day: String) -> String {
return "Hello \(name), today is \(day)."
}
greet(...
分类:
移动开发 时间:
2014-06-29 07:20:12
阅读次数:
288
“func makeIncrementer() -> (Int -> Int) {
func addOne(number: Int) -> Int {
return 1 + number
}
return addOne
}
var increment = makeIncrementer()
increment(7)”
摘录来自: Apple Inc. “T...
分类:
其他好文 时间:
2014-06-20 13:27:56
阅读次数:
161
Objects and Classes 对象和类
使用关键字 class 定义一个类,在定义类的属性的时候与常量或者变量的定义相同(继承父类的属性定义不同),方法和函数的定义也相同
class Shape {
var numberOfSides = 0
func simpleDescription() -> String {
return "A sha...
分类:
其他好文 时间:
2014-06-20 12:38:10
阅读次数:
293
Reserved space (invalid address) is protected against abnormal access. Reads from invalid address return garbage; writes to invalid address are blocked. Access to reserved space can generate exception...
分类:
其他好文 时间:
2014-06-20 11:58:31
阅读次数:
260
首先,核心函数是这个
function mHash($key){
$md=substr(md5($key),0,8);
$seed=31;
$hash=0;
for($i=0;$i
$hash=$hash*$seed+ord($md5{$i});
}
return $hash & 0x7FFFFFFF;
}
class HashServer{
private $serve...
分类:
Web程序 时间:
2014-06-20 10:36:06
阅读次数:
213
题目
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recur...
分类:
其他好文 时间:
2014-06-20 10:22:00
阅读次数:
221
6 对象与类
使用 class 可以创建一个类。一个属性的声明则是在类里作为常量或变量声明的,除了是在类的上下文中。方法和函数也是这么写的。
class Shape { var numberOfSides = 0 func simpleDescription() -> String { return "A shape with \(numberOfSides...
分类:
移动开发 时间:
2014-06-07 14:04:17
阅读次数:
236
代码清单:
<?php
/**
* 获取当前页面的完整 url
* @author ruxing.li
* @return string
*/
function getPageUrl(){
$url = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http...
分类:
Web程序 时间:
2014-06-07 13:16:27
阅读次数:
250
方法一 算法 : public int isLeft(Point P0, Point
P1,Point P2) { int abc= ((P1.X - P0.X) * (P2.Y - P0.Y) - (P2.X - P0.X) * (P1.Y -
P0.Y)); return abc; } priv...
分类:
其他好文 时间:
2014-06-07 10:33:56
阅读次数:
351
获取方法namespace WMSBAK{ public class WMSBackUp {
private string BakDBName { get { return
System.Configuration.ConfigurationManager.AppSettings...
分类:
移动开发 时间:
2014-06-07 09:38:30
阅读次数:
397