一、基础1、变量val 标志符: 声明常量; 如,val answer = 1var 标志符:声明变量; 类型推断:变量的类型由scala根据初始化变量的表达式推断而来; 鼓励使用val; 注:声明变量时不做初始化会报错。明确类型: scala的变量或函数的类型总是写在变量或函数的后面。1 ...
分类:
其他好文 时间:
2014-09-19 01:10:14
阅读次数:
378
scala混合了面向对象和函数式的特征。在函数式的编程语言中,函数是可以像其他的数据类型一样被传递和操作。这对于想将详细动作传入给算法时变得非常有用。importscala.math._
valfun=ceil_/从技术上将_的作用是将ceil方法变成了函数
res=fun(num)/num=3.14,res=4
Array(3.14,..
分类:
其他好文 时间:
2014-09-18 16:45:25
阅读次数:
188
Source:http://support.apple.com/kb/HT6441For the protection of our customers, Apple does not disclose, discuss, or confirm security issues until a ful...
分类:
移动开发 时间:
2014-09-18 14:32:34
阅读次数:
324
A turn-oriented thread and/or process synchronization facility obtains a ticket value from a monotonically increasing ticket counter and waits until a...
分类:
其他好文 时间:
2014-09-18 00:32:33
阅读次数:
343
is_sort的原型:
::is_sorted
default (1)
template
bool is_sorted (ForwardIterator first, ForwardIterator last);
custom (2)
template
bool is_sorted (ForwardIterator fir...
分类:
其他好文 时间:
2014-09-17 10:17:32
阅读次数:
220
1. A view controller’s view is not created until it needs to appear on the screen . This optimization is called lazy loading, and it can conserve memo...
分类:
其他好文 时间:
2014-09-16 18:50:10
阅读次数:
172
is_heap原型:
std::is_heap
default (1)
template
bool is_heap (RandomAccessIterator first, RandomAccessIterator last);
custom (2)
template
bool is_heap (RandomAccessI...
分类:
其他好文 时间:
2014-09-16 17:31:24
阅读次数:
202
鸭子类型:“当看到一只鸟走起来像鸭子、游泳起来像鸭子、叫起来也像鸭子,那么这只鸟就可以被称为鸭子。” 一般在动态语言里面才有,因为静态语言是强类型的,会在编译期检查类型,很难实现。但是Scala作为一门s...
分类:
其他好文 时间:
2014-09-15 23:00:39
阅读次数:
415
单例对象scala没有静态方法和静态字段。scala使用object实现,object定义了单个实例。1 object Accounts {2 private var lastNumber = 0;3 def newUniqueNumber() = { lastNumber += 1; la...
分类:
其他好文 时间:
2014-09-15 17:20:29
阅读次数:
192
简单类和无参方法:1 class Counter {2 private var value = 0; //必须初始化字段3 def increment() = value += 1 //方法默认是公有的4 def current = value5 }使用:1 val counter1 =...
分类:
其他好文 时间:
2014-09-15 17:16:29
阅读次数:
161