# Site
title: Oh Captain, My Captain - Du00
subtitle: Qzone-天涯-163-百度-新浪,削足适履,不如亲手打造
description: Du00的博客
author: Du00
email: du00cs@gmail.com
language: zh-CN
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://du00cs.github.com
# Extensions
theme: metro-light
# Deployment
deploy:
type: github
repo: https://github.com/du00cs/du00cs.github.io.git
#duoshuo_short_name是需要去“多说”申请的,填错无效……
comment:
duoshuo: true
duoshuo_short_name: du00cs
## to enable disqus, you need to fill in the disqus_shortname in config.yml
## to enable duoshuo, you need duoshuo id and set duosuo to true
#share plugins at the bottom of the article
share:
enable: true
jiathis: true ## Jiathis是一个面向国内的分享插件,你不会想分享到google/twitter的……
twitter: false
google: false
bottom_link:
github: du00cs ## 填写用户名即可
weibo: du00cs ## 填写微博数字ID或者用户名(不是昵称)
renren: ##e.g. 333333333 for http://www.renren.com/333333333
#google analytics id, 这个可以用来对网站进行统计,同样需要申请
google_analytics: UA-56718947-1
/** * Scala极速入门材料,可以直接贴入ScalaIDE的worksheet */ objecttest { println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet //val(ue) 是引用不变,不能改变val值变量的『值』 valn =8//> n : Int = 8 //n += 1 : value += is not a member of Int
//var(riable) 是变量,能用val用val,技穷用var var nn = 7//> nn : Int = 7 nn += 1 nn //> res0: Int = 8
//tuple - 使用得非常重的数据结构,同python,但是不能(显式地)按下标取到每个元素 valt = (1, "a", None) //> t : (Int, String, None.type) = (1,a,None) t._1 //> res1: Int = 1 t._2 //> res2: String = a t._3 //> res3: None.type = None //纯语法,相信看过就不会忘记的 val (no, name, score) = t //> no : Int = 1 //| name : String = a //| score : None.type = None
//collections, 取下标用() vallist =List(1, 2, 3) //> list : List[Int] = List(1, 2, 3) list(0) //> res4: Int = 1 valm =Map( "a" -> 1, "c" -> 2, "b" -> 3, "d" -> 4) //> m : scala.collection.immutable.Map[String,Int] = Map(a -> 1, c -> 2, b -> 3 //| , d -> 4) //取前两个 m.take(2) //> res5: scala.collection.immutable.Map[String,Int] = Map(a -> 1, c -> 2) m("a") //> res6: Int = 1 //删除一个键,得到一个新的map m - "a"//> res7: scala.collection.immutable.Map[String,Int] = Map(c -> 2, b -> 3, d -> //| 4)