scala good code
来源:互联网 发布:火炬之光2for mac汉化 编辑:程序博客网 时间:2024/05/11 08:48
1akka actor case class
Messages and immutability
IMPORTANT: Messages can be any kind of object but have to be immutable. Scala can’t enforce immutability (yet) so this has to be by convention. Primitives like String, Int, Boolean are always immutable. Apart from these the recommended approach is to use Scala case classes which are immutable (if you don’t explicitly expose the state) and works great with pattern matching at the receiver side.
Here is an example:
- // define the case class
- case class Register(user: User)
-
- // create a new case class message
- val message = Register(user)
2
Array.tabulate[BlockObjectWriter](numBuckets) { bucketId =>
val blockId = ShuffleBlockId(shuffleId, mapId, bucketId)
val blockFile = blockManager.diskBlockManager.getFile(blockId)
// Because of previous failures, the shuffle file may already exist on this machine.
// If so, remove it.
if (blockFile.exists) {
if (blockFile.delete()) {
logInfo(s"Removed existing shuffle file $blockFile")
} else {
logWarning(s"Failed to remove existing shuffle file $blockFile")
}
}
blockManager.getDiskWriter(blockId, blockFile, serializer, bufferSize)
}
3 a with b (b是个trait动态混入)
4 for yield
5 getorelse
- scala good code
- afx good code
- java good code
- Code Jam--Good Luck
- Good and Bad PHP Code
- A return to Good Code
- A return to Good Code
- A return to Good Code
- How Do You Define "Good Code"?
- (zz)Good and Bad PHP Code
- A return to Good Code【ZT】
- A good code base of Microsoft C#
- Weka source code sample good website
- 5-tips-for-creating-good-code-every
- Google Code Jam Notes - Good Luck - Java
- What Makes Good Code Good? [zz from MSDN Magazine July 2004]
- 5 Tips for creating good code every day; or how to become a good software developer
- Make bad code good (代码重构技巧)
- acm-汉诺塔(三)
- acm-GoroSort
- acm-递推求值
- acm-Matrix Power Series
- acm-Kiki & Little Kiki 2
- scala good code
- acm-星际旅行
- acm-K steps
- hashmap hashtable1
- acm-好多的树
- SharePoint 2013 App 开发 (2) - 建立开发环境
- acm-多边形重心问题
- acm-三点顺序
- acm-圈水池