From 3281ca0c8845b565a5459a759f421c9eceedbb12 Mon Sep 17 00:00:00 2001 From: lightsing Date: Wed, 24 May 2017 19:28:32 +0800 Subject: [PATCH 1/6] Add zh-CN tutorial translation Signed-off-by: lightsing --- zh-cn/tutorials/scala-for-java-programmers.md | 387 ++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 zh-cn/tutorials/scala-for-java-programmers.md diff --git a/zh-cn/tutorials/scala-for-java-programmers.md b/zh-cn/tutorials/scala-for-java-programmers.md new file mode 100644 index 0000000000..3e6ee1c932 --- /dev/null +++ b/zh-cn/tutorials/scala-for-java-programmers.md @@ -0,0 +1,387 @@ +--- +layout: overview +title: 给 Java 工程师的 Scala 入门教学 +overview: scala-for-java-programmers + +disqus: true +multilingual-overview: true +language: zh-cn +--- + +Michel Schinz 与 Philipp Haller 著 +Lightsing 译 + +## 介绍 + +此教学将对 Scala 语言以及编译器做一个简易介绍。面向的读者为具有变成经验且想简要了解 Scala 的人。本文假设读者有着基本、特别是 Java 上的面向对象知识。 + +## 第一个例子 + +这里用标准的 *Hello world* 程序作为第一个例子。虽然它很无趣,可是这让我们在仅用少量语言特性下演示 Scala 工具。程序如下: + + object HelloWorld { + def main(args: Array[String]) { + println("Hello, world!") + } + } + +Java 程序员应该对这个程序结构感到熟悉:这有一个`main` 函数,该函数接受一个字符串阵列参数,也就是命令列参数;函数内容为调用已定义好的函数`println ` 并用Hello world 字符串当参数。 `main` 函数没有回传值 (它是程序函数)。因此并不需要声明回传类型。 + +Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种声明引入我们一般称之 *Singleton* 的东西,也就是只有一个实例的类。所以上面的声明同时声明了一个 `HelloWorld` 类跟一个这类的实例,也叫做 `HelloWorld`。该实例会在第一次被使用到的时候即时产生。 + +眼尖的读者可能已经注意到这边 `main` 函数的声明没有带着 `static`。这是因为 Scala 没有静态成员 (函数或属性)。 Scala 程序员将这成员声明在单实例对象中,而不是定义静态成员。 + +### 编译这例子 + +我们用 Scala 编译器 `scalac`来编译这个例子。 `scalac` 就像大多数编译器一样,它接受源代码文件当对象,并接受额外的选项,然后产生一个或多个对象文件。它产出的对象文件为标准 Java class 文件。 + +如果我们将上面的程序存成 `HelloWorld.scala` 档,编译指令为( `>` 是提示字符,不用打): + + > scalac HelloWorld.scala + +这会在当前目录产生一些 class 文件。其中一个会叫做 `HelloWorld.class`,里面包含着可被 `scala` 直接执行的类。 + +### 执行示例 + +一旦编译过后,Scala 程序可以用 `scala` 指令执行。其使用方式非常像执行 Java 程序的 `java` 指令,并且接受同样选项。上面的示例可以用以下指令来执行并得到我们预期的输出: + + > scala -classpath . HelloWorld + + Hello, world! + +## 与 Java 互动 + +Scala 的优点之一是它非常容易跟 Java 代码沟通。预设导入了所有 `java.lang` 底下之类,其他类则需要明确导入。 + +让我们看个展示这点的示例。取得当下日期并根据某个特定国家调整成该国格式,如法国。 + +Java 的标准函数库定义了一些有用的工具类,如 `Date` 跟 `DateFormat`。因为 Scala 可以无缝的跟 Java 互动,这边不需要以 Scala 实作同样类-我们只需要导入对应的 Java 包: + + import java.util.{Date, Locale} + import java.text.DateFormat + import java.text.DateFormat._ + + object FrenchDate { + def main(args: Array[String]) { + val now = new Date + val df = getDateInstance(LONG, Locale.FRANCE) + println(df format now) + } + } + +Scala 的导入表达式跟 Java 非常像,但更为强大。如第一行,同一个 package 下的多个类可以用大括号括起来一起导入。另外一个差别是,当要导入套件或类下所有名称时,用下标 (`_`) 而不是星号 (`*`)。这是因为星号在 Scala 是一个合法的标识符 (如函数名称)。 + +所以第三行的表达式导入所有 `DateFormat` 类的成员。这让静态方法 `getDateInstance` 跟静态属性 `LONG` 可直接被使用。 + +在 `main` 函数中我们先创造一个 Java 的 `Date` 类实例,该实例预设拥有现在的日期。接下来用 `getDateInstance` 函数定义日期格式。最后根据地区化的 `DateFormat` 实例对现在日期设定格式并印出。最后一行展现了一个 Scala 有趣特点。只需要一个对象的函数可以用中缀语法调用。就是说,这个表达式 + + df format now + +是这个表达式的简略版本 + + df.format(now) + +这点也许看起来只是语法上的小细节,但是它有着重要的后果,其中一个将会在下一节做介绍。 + +最后值得一提的是,Scala 可以直接继承 Java 类或者实现 Java 接口。 + +## 一切都是对象 + +Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有东西*都是对象,包括数字、函数。因为 Java 将基本类型 (如 `boolean` 与 `int` ) 跟参照类型分开,而且没有办法像操作变量一样操作函数,从这角度来看 Scala 跟 Java 是不同的。 + +### 数字是对象 + +因为数字是对象,他们也有函数。事实上,一个像底下的算数表达式: + + 1 + 2 * 3 / x + +只有使用函数调用,因为像前一节一样,该式等价于 + + (1).+(((2).*(3))./(x)) + +这也表示着 `+`、`*` 之类的在 Scala 里是合法的标识符。 + +因为Scala的词法分析器对于符号采用最长匹配,在第二版的表达式当中,那些括号是必要的。也就是说分析器会把这个表达式: + + 1.+(2) + +拆成 `1.`、`+`、`2` 这三个标记。会这样拆分是因为 `1.` 既是合法匹配的同时又比 `1` 长。 `1.` 会被解释成字面常数 `1.0`,使得它被视为 `Double` 而不是 `Int`。把表达式写成: + + (1).+(2) + +可以避免 `1` 被解释成 `Double`。 + +### 函数是对象 + +可能令 Java 程序员更为惊讶的会是,Scala 中函数也是对象。因此,将函数当做对象传递、把它们存入变量、从其他函数返回函数都是可能的。能够像操作变量一样的操作函数这点是*函数式编程*这一非常有趣的程序设计思想的基石之一。 + +为何把函数当做变量一样的操作会很有用呢,让我们考虑一个定时函数,功能是每秒执行一些动作。我们要怎么将这动作传给它?最直接的便是将这动作视为函数传入。应该有不少程序员对这种简单传递函数的行为很熟悉:通常在使用者介面相关的程序上,用以注册一些当事件发生时被调用的回呼函数。 + +在接下来的程序中,定时函数叫做 `oncePerSecond` ,它接受一个回呼函数做参数。该函数的类型被写作 `() => Unit` ,这个类型便是所有无对象且无返回值函数的类型( `Unit` 这个类型就像是 C/C++ 的 `void` )。此程序的主函数只是调用定时函数并带入回呼函数,回呼函数输出一句话到终端上。也就是说这个程序会不断的每秒输出一次 "time flies like an arrow"。 + + object Timer { + def oncePerSecond(callback: () => Unit) { + while (true) { callback(); Thread sleep 1000 } + } + def timeFlies() { + println("time flies like an arrow...") + } + def main(args: Array[String]) { + oncePerSecond(timeFlies) + } + } + +值得注意的是,这边输出时我们使用 Scala 的函数 `println`,而不是 `System.out` 里的函数。 + +#### 匿名函数 + +这程序还有改进空间。第一点,函数 `timeFlies` 只是为了能够被传递进 `oncePerSecond` 而定义的。赋予一个只被使用一次的函数名字似乎是没有必要的,最好能够在传入 `oncePerSecond` 时构造出这个函数。Scala 可以借由*匿名函数*来达到这点。利用匿名函数的改进版本程序如下: + + object TimerAnonymous { + def oncePerSecond(callback: () => Unit) { + while (true) { callback(); Thread sleep 1000 } + } + def main(args: Array[String]) { + oncePerSecond(() => + println("time flies like an arrow...")) + } + } + +这例子中的右箭头 `=>` 告诉我们有一个匿名函数,右箭头将函数对象跟函数内容分开。这个例子中,在箭头左边那组空的括号告诉我们对象列是空的。函数内容则是跟先前的 `timeFlies` 里一样。 + +## 类 + +之前已讲过,Scala 是一个面向对象语言,因此它有着类的概念 (更精确的说,的确有一些面向对象语言没有类的概念,但是 Scala 不是这种)。Scala 声明类的语法跟 Java 很接近。一个重要的差别是,Scala 的类可以有参数。这边用底下复数的定义来展示: + + class Complex(real: Double, imaginary: Double) { + def re() = real + def im() = imaginary + } + +这个复数类接受两个参数,分别为实跟虚部。在创造 `Complex` 的实例时,必须传入这些参数: `new Complex(1.5, 2.3)`。这个类有两个函数分别叫做 `re` 跟 `im` 让我们取得这两个部分。 + +值得注意的是,这两个函数的回传值并没有被明确给定。编译器将会自动的推断,它会查看这些函数的右侧并推导出这两个函数都会回传类型为 `Double` 的值。 + +编译器并不一定每次都能够推断出类型,而且很不幸的是我们并没有简单规则以分辨哪种情况能推断,哪种情况不能。因为当编译器无法推断未明确给定的类型时它会回报错误,实务上这通常不是问题。Scala 初学者在遇到那些看起来很简单就能推导出类型的情况时,应该尝试着忽略类型声明并看看编译器是不是也觉得可以推断。多尝试几次之后程序员应该能够体会到何时忽略类型、何时该明确指定。 + +### 无对象函数 + +函数 `re`、`im` 有个小问题,为了调用函数,我们必须在函数名称后面加上一对空括号,如这个例子: + + object ComplexNumbers { + def main(args: Array[String]) { + val c = new Complex(1.2, 3.4) + println("imaginary part: " + c.im()) + } + } + +最好能够在不需要加括号的情况下取得实虚部,这样便像是在取得属性。Scala完全可以做到这件事,需要的只是在定义函数的时候*不要定义参数*。这种函数跟零参数函数是不一样的,不论是定义或是调用,它们都没有括号跟在名字后面。我们的 `Complex` 可以改写成: + + class Complex(real: Double, imaginary: Double) { + def re = real + def im = imaginary + } + +### 继承与重写 + +Scala 中所有的类都继承自一个父类。像前一节的 `Complex` 这种没有指定的例子,Scala 会默认使用 `scala.AnyRef`。 + +Scala 中可以重写继承自父类的函数。但是为了避免意外重写,必须加上 `override` 修饰字来明确表示要重写函数。我们以重写 `Complex` 类中来自 `Object` 的 `toString` 作为示例。 + + class Complex(real: Double, imaginary: Double) { + def re = real + def im = imaginary + override def toString() = + "" + re + (if (im < 0) "" else "+") + im + "i" + } + + +## Case Class 跟模式匹配(pattern matching) + +树是常见的数据结构。如:解译器跟编译器内部常见的表示程序方式便是树;XML文件是树;还有一些容器基于树,如红黑树。 + +接下来我们会通过一个小型计算程序来看看 Scala 是如何表示并操作树。这个程序将足以操作仅含有整数常数、整数变量跟加法的简单算术式。`1+2` 跟 `(x+x)+(7+y)` 为两个例子。 + +我们得先决定这种表达式的表示法。最自然表示法便是树,其中节点是操作、叶节点是值。 + +Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟叶节点分别有各自的实际类。在函数编程里会用代数数据类型。Scala 则是提供了介于两者之间的 *case class*。这是用其定义这样数据类型的示例: + + abstract class Tree + case class Sum(l: Tree, r: Tree) extends Tree + case class Var(n: String) extends Tree + case class Const(v: Int) extends Tree + +`Sum`、`Var`、`Const` 类定义成 case class 代表着它们跟一般类有所差别: + +- 在创建类实例时不需要用 `new` (也就是说我们可以写 `Const(5)`,而不是 `new Const(5)`)。 +- 对应所有构造参数,Scala 会自动定义对应的取值函数 (即,对于 `Const` 类的实例,我们可以直接用 `c.v` 来取得建构式中的 `v` 参数)。 +- `equals` 跟 `hashCode` 会有预设定义。该定义会根据实例的*结构*而不是个别实例的识别来运作。 +- `toString` 会有预设定义。会印出"原始型态" (即,`x+1` 的树会被印成`Sum(Var(x),Const(1))`)。 +- 这些类的实例可以借由*模式匹配*来拆解。 + +现在我们有了算术表达式的数据类型,可以开始定义各种运算。我们将从一个可以在*环境*内对运算式求值的函数起头。环境的用处是赋值给变量。举例来说,运算式 `x+1` 在一个将 `x` 赋与 `5` 的环境 (写作 `{ x -> 5 }` ) 下求值会得到 `6`。 + +因此我们需要一个表示环境的方法。当然我们可以用一些像是哈希表的关连性数据结构,但是我们也可以直接用函数!环境就只是一个将值对应到 (变量) 名称的函数。之前提到的环境 `{ x -> 5 }` 在 Scala 中可以简单的写作: + + { case "x" => 5 } + +这个标记定义了一个当输入是字符串 `"x"` 时回传整数 `5`,其他输入则是用例外表示失败的函数。 + +开始之前,让我们先给环境类型一个名字。当然,我们可以直接用 `String => Int`,但是给这类型名字可以让我们简化程序,而且在未来要改动时较为简便。在 Scala 中我们这样做: + + type Environment = String => Int + +于是类型 `Environment` 便可以当做输入 `String` 回传 `Int` 函数的类型之代名。 + +现在我们可以给出求值函数的定义。概念上非常简单:两个表达式和的值是两个表达式值的和;变量的值直接从环境取值;常数的值就是常数本身。表示这些在 Scala 里并不困难: + + def eval(t: Tree, env: Environment): Int = t match { + case Sum(l, r) => eval(l, env) + eval(r, env) + case Var(n) => env(n) + case Const(v) => v + } + +这个求值函数借由对树 `t` 做*模式匹配*来求值。上述实作的意思应该从直观上便很明确: + +1. 首先检查树 `t` 是否为 `Sum`,如果是的话将左跟右侧子树绑定到新变量 `l`跟 `r`,然后再对箭头后方的表达式求值;这一个表达式可以使用(而且这边也用到)根据箭头左侧模式所绑定的变量,也就是 `l` 跟 `r`, +2. 如果第一个检查失败,也就是说树不是 `Sum`,接下来检查 `t` 是否为 `Var`,如果是的话将 `Var` 所带的名称绑定到变量 `n` 并求值右侧表达式, +3. 如果第二个检查也失败,表示树不是 `Sum` 也不是 `Var`,那便检查是不是 `Const`,如果是的话将 `Const` 所带的名称绑定到变量 `v` 并求值右侧表达式, +4. 最后,如果全部检查都失败,会抛出异常表示匹配失败;这只会在有更多 `Tree` 的子类时发生。 + +如上,模式匹配基本上就是尝试将一个值对一系列模式做匹配,并在一个模式成功匹配时抽取并命名该值的各部分,最后对一些代码求值,而这些代码通常会利用被命名到的部位。 + +一个经验丰富的面向对象程序员也许会疑惑为何我们不将 `eval` 定义成 `Tree` 类跟子类的*方法*。由于 Scala 允许在 case class 中跟一般类一样定义函数,事实上我们可以这样做。要用模式匹配或是函数只是品味的问题,但是这会对扩充性有重要影响。 + +- 当使用函数时,只要定义新的 `Tree` 子类便新增新节点,相当容易。另一方面,增加新操作需要修改所有子类,很麻烦。 +- 当使用模式匹配时情况则反过来:增加新节点需要修改所有对树做模式匹配的函数将新节点纳入考虑;增加新操作则很简单,定义新函数就好。 + +让我们定义新操作以更进一步的探讨模式匹配:对符号求导数。读者们可能还记得这个操作的规则: + +1. 和的导数是导数的和 +2. 如果是对变量 `v` 取导数,变量 `v` 的导数是1,不然就是0 +3. 常数的导数是0 + +这些规则几乎可以从字面上直接翻成 Scala 代码: + + def derive(t: Tree, v: String): Tree = t match { + case Sum(l, r) => Sum(derive(l, v), derive(r, v)) + case Var(n) if (v == n) => Const(1) + case _ => Const(0) + } + +这个函数引入两个关于模式匹配的新观念。首先,变量的 `case` 运算式有一个*看守*,也就是 `if` 关键字之后的表达式。除非表达式求值为真,不然这个看守会让匹配直接失败。在这边是用来确定我们只在取导数变量跟被取导数变量名称相同时才回传常数 `1`。第二个新特征是可以匹配任何值的*万用字符* `_`。 + +我们还没有探讨完模式匹配的全部功能,不过为了让这份文件保持简短,先就此打住。我们还是希望能看到这两个函数在真正的示例如何作用。因此让我们写一个简单的 `main` 函数,对表达式 `(x+x)+(7+y)` 做一些操作:先在环境 `{ x -> 5, y -> 7 }` 下计算结果,然后在对 `x` 接着对 `y` 取导数。 + + def main(args: Array[String]) { + val exp: Tree = Sum(Sum(Var("x"),Var("x")),Sum(Const(7),Var("y"))) + val env: Environment = { case "x" => 5 case "y" => 7 } + println("Expression: " + exp) + println("Evaluation with x=5, y=7: " + eval(exp, env)) + println("Derivative relative to x:\n " + derive(exp, "x")) + println("Derivative relative to y:\n " + derive(exp, "y")) + } + +执行这程序,得到预期的输出: + + Expression: Sum(Sum(Var(x),Var(x)),Sum(Const(7),Var(y))) + Evaluation with x=5, y=7: 24 + Derivative relative to x: + Sum(Sum(Const(1),Const(1)),Sum(Const(0),Const(0))) + Derivative relative to y: + Sum(Sum(Const(0),Const(0)),Sum(Const(0),Const(1))) + +研究这输出我们可以发现,取导数的结果应该在输出前更进一步化简。用模式匹配实作一个基本化简函数是一个很有趣 (但是意外的棘手) 的问题,在这边留给读者当练习。 + +## 特性 (Traits) + +除了由父类继承行为以外,Scala 类还可以从一或多个*特性*导入行为。 + +对一个 Java 程序员最简单去理解特性的方式应该是视它们为带有实例的接口。在 Scala 里,当一个类继承特性时,它实作了该特性的介面并继承所有特性带有的功能。 + +为了理解特性的用处,让我们看一个经典示例:有序对象。大部分情况下,一个类所产生出来的对象之间可以互相比较大小是很有用的,如排序它们。在Java里可比较大小的对象实作 `Comparable` 介面。在Scala中借由定义等价于 `Comparable` 的特性 `Ord`,我们可以做的比Java稍微好一点。 + +当在比较对象的大小时,有六个有用且不同的谓词 (predicate):小于、小于等于、等于、不等于、大于等于、大于。但是把六个全部都实现很烦,尤其是当其中有四个可以用剩下两个表示的时候。也就是说,(举例来说) 只要有等于跟小于谓词,我们就可以表示其他四个。在 Scala 中这些观察可以很漂亮的用下面的特性声明呈现: + + trait Ord { + def < (that: Any): Boolean + def <=(that: Any): Boolean = (this < that) || (this == that) + def > (that: Any): Boolean = !(this <= that) + def >=(that: Any): Boolean = !(this < that) + } + +这份定义同时创造了一个叫做 `Ord` 的新类型,跟 Java 的 `Comparable` 接口有着同样定位,且给了一份以第一个抽象谓词表示剩下三个谓词的预设实作。因为所有对象预设都有一份等于跟不等于的谓词,这边便没有定义。 + +上面使用了一个 `Any` 类型,在 Scala 中这个类型是所有其他类型的父类型。因为它同时也是基本类型如 `Int`、`Float` 的父类型,可以将其视为更为一般化的 Java `Object` 类型。 + +因此只要定义测试相等性跟小于的谓词,并且加入 `Ord`,就可以让一个类的对象们互相比较大小。让我们实作一个表示阳历日期的 `Date` 类来做为例子。这种日期是由日、月、年组成,我们将用整数来表示这三个资料。因此我们可以定义 `Date` 类为: + + class Date(y: Int, m: Int, d: Int) extends Ord { + def year = y + def month = m + def day = d + override def toString(): String = year + "-" + month + "-" + day + +这边要注意的是声明在类名称跟参数之后的 `extends Ord`。这个语法声明了 `Date` 继承 `Ord` 特性。 + +然后我们重新定义继承自 `Object` 的 `equals` 函数好让这个类可以正确的根据每个属性来比较日期。因为在 Java 中 `equals` 直接比较实际对象本身,并不能在这边用。于是我们有下面的例子: + + override def equals(that: Any): Boolean = + that.isInstanceOf[Date] && { + val o = that.asInstanceOf[Date] + o.day == day && o.month == month && o.year == year + } + +这个函数使用了预定义函数 `isInstanceOf` 跟 `asInstanceOf`。`isInstanceOf` 对应到 Java 的 `instanceof` 运算子,只在当使用它的对象之类型跟给定类型一样时传回真。 `asInstanceOf` 对应到 Java 的转型运算子,如果对象是给定类型的实例,该对象就会被视为给定类型,不然就会丢出 `ClassCastException` 。 + +最后我们需要定义测试小于的谓词如下。 + + def <(that: Any): Boolean = { + if (!that.isInstanceOf[Date]) + error("cannot compare " + that + " and a Date") + + val o = that.asInstanceOf[Date] + (year < o.year) || + (year == o.year && (month < o.month || + (month == o.month && day < o.day))) + } + +这边使用了另外一个预定义函数 `error`,它会丢出带着给定错误信息的例外。这便完成了 `Date` 类。这个类的实例可被视为日期或是可比较对象。而且它们通通都定义了之前所提到的六个比较谓词: `equals` 跟 `<` 直接出现在类定义当中,其他则是继承自 `Ord` 特性。 + +特性在其他场合也有用,不过详细探讨它们的用途并不在本文件目标内。 + +## 泛型 + +在这份教学里,我们最后要探讨的 Scala 特性是泛型。Java 程序员应该相当清楚在 Java 1.5 之前缺乏泛型所导致的问题。 + +泛型指的是能够将类型也作为程序参数。举例来说,当程序员在为链表写函数库时,它必须决定列表的元素类型为何。由于这列表是要在许多不同场合使用,不可能决定列表的元素类型为如 `Int` 一类。这样限制太多。 + +Java 程序员采用所有对象的父类 `Object`。这个解决办法并不理想,一方面这并不能用在基础类型 (`int`、`long`、`float` 之类),再来这表示必须靠程序员手动加入大量的动态转型。 + +Scala 借由可定义泛型类 (跟函数) 来解决这问题。让我们借由最简单的类容器来检视这点:参照,它可以是空的或者指向某类型的对象。 + + class Reference[T] { + private var contents: T = _ + def set(value: T) { contents = value } + def get: T = contents + } + +类 `Reference` 带有一个类型参数 `T`,这个参数会是容器内元素的类型。此类型被用做 `contents` 变量的类型、 `set` 函数的对象类型、 `get` 函数的回传类型。 + +上面代码使用的 Scala 变量语法应该不需要过多的解释。值得注意的是赋与该变量的初始值是 `_`,该语法表示预设值。数值类型预设值是0,`Boolean` 类型是 `false`, `Unit` 类型是 `()` ,所有的对象类型是 `null`。 + +为了使用 `Reference` 类型,我们必须指定 `T`,也就是这容器所包容的元素类型。举例来说,创造并使用该容器来容纳整数,我们可以这样写: + + object IntegerReference { + def main(args: Array[String]) { + val cell = new Reference[Int] + cell.set(13) + println("Reference contains the half of " + (cell.get * 2)) + } + } + +如例子中所展现,并不需要先将 `get` 函数所回传的值转型便能当做整数使用。同时因为被声明为储存整数,也不可能存除了整数以外的东西到这一个容器中。 + +## 结语 + +本文件对Scala语言做了快速的概览并呈现一些基本的例子。对 Scala 有更多兴趣的读者可以阅读有更多进阶示例的 *Scala By Example*,并在需要的时候参阅 *Scala Language Specification* 。 From 8d75c8510a337a4e67526b42df8a6ed17b92f2b4 Mon Sep 17 00:00:00 2001 From: lightsing Date: Wed, 31 May 2017 00:01:08 +0800 Subject: [PATCH 2/6] Update Translation --- zh-cn/tutorials/scala-for-java-programmers.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/zh-cn/tutorials/scala-for-java-programmers.md b/zh-cn/tutorials/scala-for-java-programmers.md index 3e6ee1c932..4df44aa301 100644 --- a/zh-cn/tutorials/scala-for-java-programmers.md +++ b/zh-cn/tutorials/scala-for-java-programmers.md @@ -13,11 +13,11 @@ Lightsing 译 ## 介绍 -此教学将对 Scala 语言以及编译器做一个简易介绍。面向的读者为具有变成经验且想简要了解 Scala 的人。本文假设读者有着基本、特别是 Java 上的面向对象知识。 +此教学将对 Scala 语言以及编译器做一个简易介绍。面向的读者为具有编程经验,并且想简单了解 Scala 的人。本文假设读者有着基本的、最好是 Java 上的面向对象知识。 ## 第一个例子 -这里用标准的 *Hello world* 程序作为第一个例子。虽然它很无趣,可是这让我们在仅用少量语言特性下演示 Scala 工具。程序如下: +这里用标准的 *Hello world* 程序作为第一个例子。虽然它很无趣,但让我们可以用少量语言特质来演示 Scala 工具。程序如下: object HelloWorld { def main(args: Array[String]) { @@ -25,17 +25,17 @@ Lightsing 译 } } -Java 程序员应该对这个程序结构感到熟悉:这有一个`main` 函数,该函数接受一个字符串阵列参数,也就是命令列参数;函数内容为调用已定义好的函数`println ` 并用Hello world 字符串当参数。 `main` 函数没有回传值 (它是程序函数)。因此并不需要声明回传类型。 +Java 程序员应该对这个程序结构感到熟悉:这有一个`main` 函数,该函数接受一个字符串数组作为参数,即命令行参数;函数内容为调用已定义好的函数`println ` 并用Hello world 字符串当参数。 `main` 函数没有返回值 (它是一个过程方法)。因此并不需要声明返回值类型。 -Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种声明引入我们一般称之 *Singleton* 的东西,也就是只有一个实例的类。所以上面的声明同时声明了一个 `HelloWorld` 类跟一个这类的实例,也叫做 `HelloWorld`。该实例会在第一次被使用到的时候即时产生。 +Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种声明引入我们一般称之 *Singleton* 的东西,也就是只有一个实例的类。所以上面的代码同时声明了一个 `HelloWorld` 类和一个这类的实例,也叫做 `HelloWorld`。该实例会在第一次被使用到的时候即时产生。 眼尖的读者可能已经注意到这边 `main` 函数的声明没有带着 `static`。这是因为 Scala 没有静态成员 (函数或属性)。 Scala 程序员将这成员声明在单实例对象中,而不是定义静态成员。 -### 编译这例子 +### 编译这个例子 我们用 Scala 编译器 `scalac`来编译这个例子。 `scalac` 就像大多数编译器一样,它接受源代码文件当对象,并接受额外的选项,然后产生一个或多个对象文件。它产出的对象文件为标准 Java class 文件。 -如果我们将上面的程序存成 `HelloWorld.scala` 档,编译指令为( `>` 是提示字符,不用打): +如果我们将上面的程序存为文件 `HelloWorld.scala` 档,编译指令为( `>` 是提示字符,不用打): > scalac HelloWorld.scala @@ -51,7 +51,7 @@ Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种 ## 与 Java 互动 -Scala 的优点之一是它非常容易跟 Java 代码沟通。预设导入了所有 `java.lang` 底下之类,其他类则需要明确导入。 +Scala 的优点之一是它非常容易跟 Java 代码沟通。Scala 会默认 import `java.lang` 底下之类,其他类则需要明确导入。 让我们看个展示这点的示例。取得当下日期并根据某个特定国家调整成该国格式,如法国。 @@ -73,7 +73,7 @@ Scala 的导入表达式跟 Java 非常像,但更为强大。如第一行, 所以第三行的表达式导入所有 `DateFormat` 类的成员。这让静态方法 `getDateInstance` 跟静态属性 `LONG` 可直接被使用。 -在 `main` 函数中我们先创造一个 Java 的 `Date` 类实例,该实例预设拥有现在的日期。接下来用 `getDateInstance` 函数定义日期格式。最后根据地区化的 `DateFormat` 实例对现在日期设定格式并印出。最后一行展现了一个 Scala 有趣特点。只需要一个对象的函数可以用中缀语法调用。就是说,这个表达式 +在 `main` 函数中我们先创造一个 Java 的 `Date` 类实例,该实例默认拥有现在的日期。接下来用 `getDateInstance` 函数定义日期格式。最后根据地区化的 `DateFormat` 实例对现在日期设定格式并印出。最后一行展现了一个 Scala 有趣特点。只需要一个对象的函数可以用中缀语法调用。就是说,这个表达式 df format now @@ -81,7 +81,7 @@ Scala 的导入表达式跟 Java 非常像,但更为强大。如第一行, df.format(now) -这点也许看起来只是语法上的小细节,但是它有着重要的后果,其中一个将会在下一节做介绍。 +它看起来也许只是语法上的小细节,但却有着重要的影响,其中一个影响将会在下一节做介绍。 最后值得一提的是,Scala 可以直接继承 Java 类或者实现 Java 接口。 @@ -115,9 +115,9 @@ Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有 可能令 Java 程序员更为惊讶的会是,Scala 中函数也是对象。因此,将函数当做对象传递、把它们存入变量、从其他函数返回函数都是可能的。能够像操作变量一样的操作函数这点是*函数式编程*这一非常有趣的程序设计思想的基石之一。 -为何把函数当做变量一样的操作会很有用呢,让我们考虑一个定时函数,功能是每秒执行一些动作。我们要怎么将这动作传给它?最直接的便是将这动作视为函数传入。应该有不少程序员对这种简单传递函数的行为很熟悉:通常在使用者介面相关的程序上,用以注册一些当事件发生时被调用的回呼函数。 +为何把函数当做变量一样的操作会很有用呢,让我们考虑一个定时函数,功能是每秒执行一些动作。我们要怎么将这动作传给它?最直接的便是将这动作视为函数传入。应该有不少程序员对这种简单传递函数的行为很熟悉:通常在用户界面相关的程序上,用来注册一些当事件发生时被调用的回调函数。 -在接下来的程序中,定时函数叫做 `oncePerSecond` ,它接受一个回呼函数做参数。该函数的类型被写作 `() => Unit` ,这个类型便是所有无对象且无返回值函数的类型( `Unit` 这个类型就像是 C/C++ 的 `void` )。此程序的主函数只是调用定时函数并带入回呼函数,回呼函数输出一句话到终端上。也就是说这个程序会不断的每秒输出一次 "time flies like an arrow"。 +在接下来的程序中,定时函数叫做 `oncePerSecond` ,它接受一个回调函数做参数。该函数的类型被写作 `() => Unit` ,这个类型便是所有无对象且无返回值函数的类型( `Unit` 这个类型就像是 C/C++ 的 `void` )。此程序的主函数只是调用定时函数并带入回呼函数,回呼函数输出一句话到终端上。也就是说这个程序会不断的每秒输出一次 "time flies like an arrow"。 object Timer { def oncePerSecond(callback: () => Unit) { @@ -131,7 +131,7 @@ Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有 } } -值得注意的是,这边输出时我们使用 Scala 的函数 `println`,而不是 `System.out` 里的函数。 +值得注意的是,在打印字符串时,我们使用的是 Scala 预定义的方法 `println`,而不是 `System.out` 中的。 #### 匿名函数 @@ -151,7 +151,7 @@ Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有 ## 类 -之前已讲过,Scala 是一个面向对象语言,因此它有着类的概念 (更精确的说,的确有一些面向对象语言没有类的概念,但是 Scala 不是这种)。Scala 声明类的语法跟 Java 很接近。一个重要的差别是,Scala 的类可以有参数。这边用底下复数的定义来展示: +之前已讲过,Scala 是一个面向对象语言,因此它有着类的概念 (更精确的说,的确有一些面向对象语言没有类的概念,但是 Scala 不是其中之一)。Scala 声明类的语法跟 Java 很接近。一个重要的差别是,Scala 的类可以有参数。如下面展示的复数的定义: class Complex(real: Double, imaginary: Double) { def re() = real @@ -162,7 +162,7 @@ Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有 值得注意的是,这两个函数的回传值并没有被明确给定。编译器将会自动的推断,它会查看这些函数的右侧并推导出这两个函数都会回传类型为 `Double` 的值。 -编译器并不一定每次都能够推断出类型,而且很不幸的是我们并没有简单规则以分辨哪种情况能推断,哪种情况不能。因为当编译器无法推断未明确给定的类型时它会回报错误,实务上这通常不是问题。Scala 初学者在遇到那些看起来很简单就能推导出类型的情况时,应该尝试着忽略类型声明并看看编译器是不是也觉得可以推断。多尝试几次之后程序员应该能够体会到何时忽略类型、何时该明确指定。 +编译器并不一定每次都能够推断出类型,而且很不幸的是我们并没有简单规则以分辨哪种情况能推断,哪种情况不能。实践上这通常不是问题,因为当编译器无法推断未明确给定的类型时,它会报错。Scala 初学者在遇到那些看起来很简单就能推导出类型的情况时,应该尝试着忽略类型声明并看看编译器是不是也觉得可以推断。多尝试几次之后程序员应该能够体会到何时忽略类型、何时该明确指定。 ### 无对象函数 @@ -248,11 +248,11 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 3. 如果第二个检查也失败,表示树不是 `Sum` 也不是 `Var`,那便检查是不是 `Const`,如果是的话将 `Const` 所带的名称绑定到变量 `v` 并求值右侧表达式, 4. 最后,如果全部检查都失败,会抛出异常表示匹配失败;这只会在有更多 `Tree` 的子类时发生。 -如上,模式匹配基本上就是尝试将一个值对一系列模式做匹配,并在一个模式成功匹配时抽取并命名该值的各部分,最后对一些代码求值,而这些代码通常会利用被命名到的部位。 +如上,模式匹配基本上就是尝试将一个值对一系列模式做匹配,并在一个模式成功匹配时抽取并命名该值的各部分,最后对一些代码求值,而这些代码通常会利用被命名到的部分。 一个经验丰富的面向对象程序员也许会疑惑为何我们不将 `eval` 定义成 `Tree` 类跟子类的*方法*。由于 Scala 允许在 case class 中跟一般类一样定义函数,事实上我们可以这样做。要用模式匹配或是函数只是品味的问题,但是这会对扩充性有重要影响。 -- 当使用函数时,只要定义新的 `Tree` 子类便新增新节点,相当容易。另一方面,增加新操作需要修改所有子类,很麻烦。 +- 当使用函数时,增加新的节点类型是相当容易的,只要定义新的 `Tree` 子类即可。不过另一方面,为树增加新操作很麻烦,因为它需要修改 `Tree` 的所有子类。 - 当使用模式匹配时情况则反过来:增加新节点需要修改所有对树做模式匹配的函数将新节点纳入考虑;增加新操作则很简单,定义新函数就好。 让我们定义新操作以更进一步的探讨模式匹配:对符号求导数。读者们可能还记得这个操作的规则: @@ -291,17 +291,17 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 Derivative relative to y: Sum(Sum(Const(0),Const(0)),Sum(Const(0),Const(1))) -研究这输出我们可以发现,取导数的结果应该在输出前更进一步化简。用模式匹配实作一个基本化简函数是一个很有趣 (但是意外的棘手) 的问题,在这边留给读者当练习。 +研究这输出我们可以发现,取导数的结果应该在输出前更进一步化简。用用模式匹配实现一个基本化简函数是一个很有趣 (但是意外的棘手) 的问题,在这边留给读者当练习。 -## 特性 (Traits) +## 特质 (Traits) -除了由父类继承行为以外,Scala 类还可以从一或多个*特性*导入行为。 +除了由父类继承行为以外,Scala 类还可以从一或多个*特质*导入行为。 -对一个 Java 程序员最简单去理解特性的方式应该是视它们为带有实例的接口。在 Scala 里,当一个类继承特性时,它实作了该特性的介面并继承所有特性带有的功能。 +对一个 Java 程序员最简单去理解特质的方式应该是视它们为带有实例的接口。在 Scala 里,当一个类继承特质时,它实现了该特质的接口并继承所有特质带有的功能。 -为了理解特性的用处,让我们看一个经典示例:有序对象。大部分情况下,一个类所产生出来的对象之间可以互相比较大小是很有用的,如排序它们。在Java里可比较大小的对象实作 `Comparable` 介面。在Scala中借由定义等价于 `Comparable` 的特性 `Ord`,我们可以做的比Java稍微好一点。 +为了理解特质的用处,让我们看一个经典示例:有序对象。大部分情况下,一个类所产生出来的对象之间可以互相比较大小是很有用的,如排序它们。在Java里可比较大小的对象实作 `Comparable` 介面。在Scala中借由定义等价于 `Comparable` 的特质 `Ord`,我们可以做的比Java稍微好一点。 -当在比较对象的大小时,有六个有用且不同的谓词 (predicate):小于、小于等于、等于、不等于、大于等于、大于。但是把六个全部都实现很烦,尤其是当其中有四个可以用剩下两个表示的时候。也就是说,(举例来说) 只要有等于跟小于谓词,我们就可以表示其他四个。在 Scala 中这些观察可以很漂亮的用下面的特性声明呈现: +当在比较对象的大小时,有六个有用且不同的谓词 (predicate):小于、小于等于、等于、不等于、大于等于、大于。但是把六个全部都实现很烦,尤其是当其中有四个可以用剩下两个表示的时候。也就是说,(举例来说) 只要有等于跟小于谓词,我们就可以表示其他四个。在 Scala 中这些观察可以很漂亮的用下面的特质声明呈现: trait Ord { def < (that: Any): Boolean @@ -322,7 +322,7 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 def day = d override def toString(): String = year + "-" + month + "-" + day -这边要注意的是声明在类名称跟参数之后的 `extends Ord`。这个语法声明了 `Date` 继承 `Ord` 特性。 +这边要注意的是声明在类名称跟参数之后的 `extends Ord`。这个语法声明了 `Date` 继承 `Ord` 特质。 然后我们重新定义继承自 `Object` 的 `equals` 函数好让这个类可以正确的根据每个属性来比较日期。因为在 Java 中 `equals` 直接比较实际对象本身,并不能在这边用。于是我们有下面的例子: @@ -346,19 +346,19 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 (month == o.month && day < o.day))) } -这边使用了另外一个预定义函数 `error`,它会丢出带着给定错误信息的例外。这便完成了 `Date` 类。这个类的实例可被视为日期或是可比较对象。而且它们通通都定义了之前所提到的六个比较谓词: `equals` 跟 `<` 直接出现在类定义当中,其他则是继承自 `Ord` 特性。 +这边使用了另外一个预定义函数 `error`,它会丢出带着给定错误信息的例外。这便完成了 `Date` 类。这个类的实例可被视为日期或是可比较对象。而且它们通通都定义了之前所提到的六个比较谓词: `equals` 跟 `<` 直接出现在类定义当中,其他则是继承自 `Ord` 特质。 -特性在其他场合也有用,不过详细探讨它们的用途并不在本文件目标内。 +特质在其他场合也有用,不过详细探讨它们的用途并不在本文件目标内。 ## 泛型 -在这份教学里,我们最后要探讨的 Scala 特性是泛型。Java 程序员应该相当清楚在 Java 1.5 之前缺乏泛型所导致的问题。 +在这份教学里,我们最后要探讨的 Scala 特质是泛型。Java 程序员应该相当清楚在 Java 1.5 之前缺乏泛型所导致的问题。 泛型指的是能够将类型也作为程序参数。举例来说,当程序员在为链表写函数库时,它必须决定列表的元素类型为何。由于这列表是要在许多不同场合使用,不可能决定列表的元素类型为如 `Int` 一类。这样限制太多。 Java 程序员采用所有对象的父类 `Object`。这个解决办法并不理想,一方面这并不能用在基础类型 (`int`、`long`、`float` 之类),再来这表示必须靠程序员手动加入大量的动态转型。 -Scala 借由可定义泛型类 (跟函数) 来解决这问题。让我们借由最简单的类容器来检视这点:参照,它可以是空的或者指向某类型的对象。 +Scala 借由可定义泛型类 (跟函数) 来解决这问题。让我们借由最简单的类容器来观察这点:引用,它可以是空的或者指向某类型的对象。 class Reference[T] { private var contents: T = _ From 892348df22f8a3694c753d537f1a6675fe76a1b8 Mon Sep 17 00:00:00 2001 From: lightsing Date: Wed, 31 May 2017 16:48:01 +0800 Subject: [PATCH 3/6] Fix typo --- zh-cn/tutorials/scala-for-java-programmers.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zh-cn/tutorials/scala-for-java-programmers.md b/zh-cn/tutorials/scala-for-java-programmers.md index 4df44aa301..939495352a 100644 --- a/zh-cn/tutorials/scala-for-java-programmers.md +++ b/zh-cn/tutorials/scala-for-java-programmers.md @@ -27,7 +27,7 @@ Lightsing 译 Java 程序员应该对这个程序结构感到熟悉:这有一个`main` 函数,该函数接受一个字符串数组作为参数,即命令行参数;函数内容为调用已定义好的函数`println ` 并用Hello world 字符串当参数。 `main` 函数没有返回值 (它是一个过程方法)。因此并不需要声明返回值类型。 -Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种声明引入我们一般称之 *Singleton* 的东西,也就是只有一个实例的类。所以上面的代码同时声明了一个 `HelloWorld` 类和一个这类的实例,也叫做 `HelloWorld`。该实例会在第一次被使用到的时候即时产生。 +Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种声明引入我们一般称之 *Singleton* 的东西,也就是只有一个实例的类。所以上面的代码同时声明了一个 `HelloWorld` 类和一个该类的实例,也叫做 `HelloWorld`。该实例会在第一次被使用到的时候即时产生。 眼尖的读者可能已经注意到这边 `main` 函数的声明没有带着 `static`。这是因为 Scala 没有静态成员 (函数或属性)。 Scala 程序员将这成员声明在单实例对象中,而不是定义静态成员。 @@ -35,7 +35,7 @@ Java 程序员不太熟悉的是包着 `main` 函数的 `object` 声明。这种 我们用 Scala 编译器 `scalac`来编译这个例子。 `scalac` 就像大多数编译器一样,它接受源代码文件当对象,并接受额外的选项,然后产生一个或多个对象文件。它产出的对象文件为标准 Java class 文件。 -如果我们将上面的程序存为文件 `HelloWorld.scala` 档,编译指令为( `>` 是提示字符,不用打): +如果我们将上面的程序存为文件 `HelloWorld.scala`,编译指令为( `>` 是提示字符,不用打): > scalac HelloWorld.scala @@ -291,7 +291,7 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 Derivative relative to y: Sum(Sum(Const(0),Const(0)),Sum(Const(0),Const(1))) -研究这输出我们可以发现,取导数的结果应该在输出前更进一步化简。用用模式匹配实现一个基本化简函数是一个很有趣 (但是意外的棘手) 的问题,在这边留给读者当练习。 +研究这输出我们可以发现,取导数的结果应该在输出前更进一步化简。用模式匹配实现一个基本化简函数是一个很有趣 (但是意外的棘手) 的问题,在这边留给读者当练习。 ## 特质 (Traits) @@ -352,7 +352,7 @@ Java 中我们会将这个树用一个抽象父类表示,然后每种节点跟 ## 泛型 -在这份教学里,我们最后要探讨的 Scala 特质是泛型。Java 程序员应该相当清楚在 Java 1.5 之前缺乏泛型所导致的问题。 +在这份教学里,我们最后要探讨的 Scala 特性是泛型。Java 程序员应该相当清楚在 Java 1.5 之前缺乏泛型所导致的问题。 泛型指的是能够将类型也作为程序参数。举例来说,当程序员在为链表写函数库时,它必须决定列表的元素类型为何。由于这列表是要在许多不同场合使用,不可能决定列表的元素类型为如 `Int` 一类。这样限制太多。 From b315e38d7ccf14bb53a0512999b6d19150b194ca Mon Sep 17 00:00:00 2001 From: lightsing Date: Tue, 9 Jan 2018 22:02:42 -0800 Subject: [PATCH 4/6] rename --- {zh-cn => _zh-cn}/overviews/collections/arrays.md | 0 .../collections/concrete-immutable-collection-classes.md | 0 .../overviews/collections/concrete-mutable-collection-classes.md | 0 .../collections/conversions-between-java-and-scala-collections.md | 0 .../overviews/collections/creating-collections-from-scratch.md | 0 {zh-cn => _zh-cn}/overviews/collections/equality.md | 0 {zh-cn => _zh-cn}/overviews/collections/introduction.md | 0 {zh-cn => _zh-cn}/overviews/collections/iterators.md | 0 {zh-cn => _zh-cn}/overviews/collections/maps.md | 0 .../overviews/collections/migrating-from-scala-27.md | 0 {zh-cn => _zh-cn}/overviews/collections/overview.md | 0 .../overviews/collections/performance-characteristics.md | 0 {zh-cn => _zh-cn}/overviews/collections/seqs.md | 0 {zh-cn => _zh-cn}/overviews/collections/sets.md | 0 {zh-cn => _zh-cn}/overviews/collections/strings.md | 0 {zh-cn => _zh-cn}/overviews/collections/trait-iterable.md | 0 {zh-cn => _zh-cn}/overviews/collections/trait-traversable.md | 0 {zh-cn => _zh-cn}/overviews/collections/views.md | 0 {zh-cn => _zh-cn}/overviews/core/actors-migration-guide.md | 0 {zh-cn => _zh-cn}/overviews/core/actors.md | 0 .../overviews/core/architecture-of-scala-collections.md | 0 {zh-cn => _zh-cn}/overviews/core/futures.md | 0 {zh-cn => _zh-cn}/overviews/core/implicit-classes.md | 0 {zh-cn => _zh-cn}/overviews/core/string-interpolation.md | 0 {zh-cn => _zh-cn}/overviews/core/value-classes.md | 0 {zh-cn => _zh-cn}/overviews/index.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/architecture.md | 0 .../parallel-collections/concrete-parallel-collections.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/configuration.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/conversions.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/ctries.md | 0 .../overviews/parallel-collections/custom-parallel-collections.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/overview.md | 0 {zh-cn => _zh-cn}/overviews/parallel-collections/performance.md | 0 {zh-cn => _zh-cn}/overviews/thanks.md | 0 {zh-cn => _zh-cn}/tutorials/scala-for-java-programmers.md | 0 36 files changed, 0 insertions(+), 0 deletions(-) rename {zh-cn => _zh-cn}/overviews/collections/arrays.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/concrete-immutable-collection-classes.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/concrete-mutable-collection-classes.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/conversions-between-java-and-scala-collections.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/creating-collections-from-scratch.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/equality.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/introduction.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/iterators.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/maps.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/migrating-from-scala-27.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/overview.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/performance-characteristics.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/seqs.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/sets.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/strings.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/trait-iterable.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/trait-traversable.md (100%) rename {zh-cn => _zh-cn}/overviews/collections/views.md (100%) rename {zh-cn => _zh-cn}/overviews/core/actors-migration-guide.md (100%) rename {zh-cn => _zh-cn}/overviews/core/actors.md (100%) rename {zh-cn => _zh-cn}/overviews/core/architecture-of-scala-collections.md (100%) rename {zh-cn => _zh-cn}/overviews/core/futures.md (100%) rename {zh-cn => _zh-cn}/overviews/core/implicit-classes.md (100%) rename {zh-cn => _zh-cn}/overviews/core/string-interpolation.md (100%) rename {zh-cn => _zh-cn}/overviews/core/value-classes.md (100%) rename {zh-cn => _zh-cn}/overviews/index.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/architecture.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/concrete-parallel-collections.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/configuration.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/conversions.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/ctries.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/custom-parallel-collections.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/overview.md (100%) rename {zh-cn => _zh-cn}/overviews/parallel-collections/performance.md (100%) rename {zh-cn => _zh-cn}/overviews/thanks.md (100%) rename {zh-cn => _zh-cn}/tutorials/scala-for-java-programmers.md (100%) diff --git a/zh-cn/overviews/collections/arrays.md b/_zh-cn/overviews/collections/arrays.md similarity index 100% rename from zh-cn/overviews/collections/arrays.md rename to _zh-cn/overviews/collections/arrays.md diff --git a/zh-cn/overviews/collections/concrete-immutable-collection-classes.md b/_zh-cn/overviews/collections/concrete-immutable-collection-classes.md similarity index 100% rename from zh-cn/overviews/collections/concrete-immutable-collection-classes.md rename to _zh-cn/overviews/collections/concrete-immutable-collection-classes.md diff --git a/zh-cn/overviews/collections/concrete-mutable-collection-classes.md b/_zh-cn/overviews/collections/concrete-mutable-collection-classes.md similarity index 100% rename from zh-cn/overviews/collections/concrete-mutable-collection-classes.md rename to _zh-cn/overviews/collections/concrete-mutable-collection-classes.md diff --git a/zh-cn/overviews/collections/conversions-between-java-and-scala-collections.md b/_zh-cn/overviews/collections/conversions-between-java-and-scala-collections.md similarity index 100% rename from zh-cn/overviews/collections/conversions-between-java-and-scala-collections.md rename to _zh-cn/overviews/collections/conversions-between-java-and-scala-collections.md diff --git a/zh-cn/overviews/collections/creating-collections-from-scratch.md b/_zh-cn/overviews/collections/creating-collections-from-scratch.md similarity index 100% rename from zh-cn/overviews/collections/creating-collections-from-scratch.md rename to _zh-cn/overviews/collections/creating-collections-from-scratch.md diff --git a/zh-cn/overviews/collections/equality.md b/_zh-cn/overviews/collections/equality.md similarity index 100% rename from zh-cn/overviews/collections/equality.md rename to _zh-cn/overviews/collections/equality.md diff --git a/zh-cn/overviews/collections/introduction.md b/_zh-cn/overviews/collections/introduction.md similarity index 100% rename from zh-cn/overviews/collections/introduction.md rename to _zh-cn/overviews/collections/introduction.md diff --git a/zh-cn/overviews/collections/iterators.md b/_zh-cn/overviews/collections/iterators.md similarity index 100% rename from zh-cn/overviews/collections/iterators.md rename to _zh-cn/overviews/collections/iterators.md diff --git a/zh-cn/overviews/collections/maps.md b/_zh-cn/overviews/collections/maps.md similarity index 100% rename from zh-cn/overviews/collections/maps.md rename to _zh-cn/overviews/collections/maps.md diff --git a/zh-cn/overviews/collections/migrating-from-scala-27.md b/_zh-cn/overviews/collections/migrating-from-scala-27.md similarity index 100% rename from zh-cn/overviews/collections/migrating-from-scala-27.md rename to _zh-cn/overviews/collections/migrating-from-scala-27.md diff --git a/zh-cn/overviews/collections/overview.md b/_zh-cn/overviews/collections/overview.md similarity index 100% rename from zh-cn/overviews/collections/overview.md rename to _zh-cn/overviews/collections/overview.md diff --git a/zh-cn/overviews/collections/performance-characteristics.md b/_zh-cn/overviews/collections/performance-characteristics.md similarity index 100% rename from zh-cn/overviews/collections/performance-characteristics.md rename to _zh-cn/overviews/collections/performance-characteristics.md diff --git a/zh-cn/overviews/collections/seqs.md b/_zh-cn/overviews/collections/seqs.md similarity index 100% rename from zh-cn/overviews/collections/seqs.md rename to _zh-cn/overviews/collections/seqs.md diff --git a/zh-cn/overviews/collections/sets.md b/_zh-cn/overviews/collections/sets.md similarity index 100% rename from zh-cn/overviews/collections/sets.md rename to _zh-cn/overviews/collections/sets.md diff --git a/zh-cn/overviews/collections/strings.md b/_zh-cn/overviews/collections/strings.md similarity index 100% rename from zh-cn/overviews/collections/strings.md rename to _zh-cn/overviews/collections/strings.md diff --git a/zh-cn/overviews/collections/trait-iterable.md b/_zh-cn/overviews/collections/trait-iterable.md similarity index 100% rename from zh-cn/overviews/collections/trait-iterable.md rename to _zh-cn/overviews/collections/trait-iterable.md diff --git a/zh-cn/overviews/collections/trait-traversable.md b/_zh-cn/overviews/collections/trait-traversable.md similarity index 100% rename from zh-cn/overviews/collections/trait-traversable.md rename to _zh-cn/overviews/collections/trait-traversable.md diff --git a/zh-cn/overviews/collections/views.md b/_zh-cn/overviews/collections/views.md similarity index 100% rename from zh-cn/overviews/collections/views.md rename to _zh-cn/overviews/collections/views.md diff --git a/zh-cn/overviews/core/actors-migration-guide.md b/_zh-cn/overviews/core/actors-migration-guide.md similarity index 100% rename from zh-cn/overviews/core/actors-migration-guide.md rename to _zh-cn/overviews/core/actors-migration-guide.md diff --git a/zh-cn/overviews/core/actors.md b/_zh-cn/overviews/core/actors.md similarity index 100% rename from zh-cn/overviews/core/actors.md rename to _zh-cn/overviews/core/actors.md diff --git a/zh-cn/overviews/core/architecture-of-scala-collections.md b/_zh-cn/overviews/core/architecture-of-scala-collections.md similarity index 100% rename from zh-cn/overviews/core/architecture-of-scala-collections.md rename to _zh-cn/overviews/core/architecture-of-scala-collections.md diff --git a/zh-cn/overviews/core/futures.md b/_zh-cn/overviews/core/futures.md similarity index 100% rename from zh-cn/overviews/core/futures.md rename to _zh-cn/overviews/core/futures.md diff --git a/zh-cn/overviews/core/implicit-classes.md b/_zh-cn/overviews/core/implicit-classes.md similarity index 100% rename from zh-cn/overviews/core/implicit-classes.md rename to _zh-cn/overviews/core/implicit-classes.md diff --git a/zh-cn/overviews/core/string-interpolation.md b/_zh-cn/overviews/core/string-interpolation.md similarity index 100% rename from zh-cn/overviews/core/string-interpolation.md rename to _zh-cn/overviews/core/string-interpolation.md diff --git a/zh-cn/overviews/core/value-classes.md b/_zh-cn/overviews/core/value-classes.md similarity index 100% rename from zh-cn/overviews/core/value-classes.md rename to _zh-cn/overviews/core/value-classes.md diff --git a/zh-cn/overviews/index.md b/_zh-cn/overviews/index.md similarity index 100% rename from zh-cn/overviews/index.md rename to _zh-cn/overviews/index.md diff --git a/zh-cn/overviews/parallel-collections/architecture.md b/_zh-cn/overviews/parallel-collections/architecture.md similarity index 100% rename from zh-cn/overviews/parallel-collections/architecture.md rename to _zh-cn/overviews/parallel-collections/architecture.md diff --git a/zh-cn/overviews/parallel-collections/concrete-parallel-collections.md b/_zh-cn/overviews/parallel-collections/concrete-parallel-collections.md similarity index 100% rename from zh-cn/overviews/parallel-collections/concrete-parallel-collections.md rename to _zh-cn/overviews/parallel-collections/concrete-parallel-collections.md diff --git a/zh-cn/overviews/parallel-collections/configuration.md b/_zh-cn/overviews/parallel-collections/configuration.md similarity index 100% rename from zh-cn/overviews/parallel-collections/configuration.md rename to _zh-cn/overviews/parallel-collections/configuration.md diff --git a/zh-cn/overviews/parallel-collections/conversions.md b/_zh-cn/overviews/parallel-collections/conversions.md similarity index 100% rename from zh-cn/overviews/parallel-collections/conversions.md rename to _zh-cn/overviews/parallel-collections/conversions.md diff --git a/zh-cn/overviews/parallel-collections/ctries.md b/_zh-cn/overviews/parallel-collections/ctries.md similarity index 100% rename from zh-cn/overviews/parallel-collections/ctries.md rename to _zh-cn/overviews/parallel-collections/ctries.md diff --git a/zh-cn/overviews/parallel-collections/custom-parallel-collections.md b/_zh-cn/overviews/parallel-collections/custom-parallel-collections.md similarity index 100% rename from zh-cn/overviews/parallel-collections/custom-parallel-collections.md rename to _zh-cn/overviews/parallel-collections/custom-parallel-collections.md diff --git a/zh-cn/overviews/parallel-collections/overview.md b/_zh-cn/overviews/parallel-collections/overview.md similarity index 100% rename from zh-cn/overviews/parallel-collections/overview.md rename to _zh-cn/overviews/parallel-collections/overview.md diff --git a/zh-cn/overviews/parallel-collections/performance.md b/_zh-cn/overviews/parallel-collections/performance.md similarity index 100% rename from zh-cn/overviews/parallel-collections/performance.md rename to _zh-cn/overviews/parallel-collections/performance.md diff --git a/zh-cn/overviews/thanks.md b/_zh-cn/overviews/thanks.md similarity index 100% rename from zh-cn/overviews/thanks.md rename to _zh-cn/overviews/thanks.md diff --git a/zh-cn/tutorials/scala-for-java-programmers.md b/_zh-cn/tutorials/scala-for-java-programmers.md similarity index 100% rename from zh-cn/tutorials/scala-for-java-programmers.md rename to _zh-cn/tutorials/scala-for-java-programmers.md From ec720e4fb7dd8bb1e3b34a94571228a336c80f02 Mon Sep 17 00:00:00 2001 From: lightsing Date: Tue, 9 Jan 2018 22:08:14 -0800 Subject: [PATCH 5/6] merge scala-master --- .drone.yml | 7 +- .drone.yml.sig | 2 +- .gitignore | 2 + CNAME | 1 - CODE_OF_CONDUCT.md | 78 + Gemfile | 12 +- Gemfile.lock | 140 +- README.md | 13 +- {ba => _ba}/cheatsheets/index.md | 8 +- _ba/tour/abstract-types.md | 86 + _ba/tour/annotations.md | 138 + _ba/tour/basics.md | 315 + _ba/tour/by-name-parameters.md | 49 + _ba/tour/case-classes.md | 63 + _ba/tour/classes.md | 125 + .../tour/compound-types.md | 54 +- _ba/tour/currying.md | 47 + _ba/tour/default-parameter-values.md | 49 + _ba/tour/extractor-objects.md | 67 + _ba/tour/for-comprehensions.md | 58 + _ba/tour/generic-classes.md | 71 + .../tour/higher-order-functions.md | 48 +- .../tour/implicit-conversions.md | 52 +- _ba/tour/implicit-parameters.md | 71 + _ba/tour/inner-classes.md | 96 + .../tour/local-type-inference.md | 67 +- _ba/tour/lower-type-bounds.md | 76 + _ba/tour/mixin-class-composition.md | 92 + _ba/tour/named-arguments.md | 39 + _ba/tour/nested-functions.md | 38 + _ba/tour/operators.md | 87 + _ba/tour/pattern-matching.md | 161 + _ba/tour/polymorphic-methods.md | 38 + _ba/tour/regular-expression-patterns.md | 65 + _ba/tour/self-types.md | 42 + .../tour/singleton-objects.md | 58 +- .../tour/tour-of-scala.md | 21 +- _ba/tour/traits.md | 87 + _ba/tour/unified-types.md | 95 + _ba/tour/upper-type-bounds.md | 55 + _ba/tour/variances.md | 183 + _books/1-programming-in-scala-3rd.md | 12 + _books/2-scala-for-the-impatient.md | 22 + _books/3-programming-scala.md | 11 + _books/4-functional-programming-in-scala.md | 11 + _books/5-scala-in-depth.md | 11 + _books/6-scala-puzzlers.md | 11 + _config.yml | 67 +- _data/doc-nav-header.yml | 37 + _data/docnames.yml | 8 + _data/footer.yml | 54 + _data/nav-header.yml | 12 + _data/overviews.yml | 223 + _data/sip-data.yml | 27 + _data/translations.yml | 2 + .../tutorials/scala-for-java-programmers.md | 9 +- {es => _es}/overviews/core/actors.md | 10 +- .../overviews/core/string-interpolation.md | 23 +- .../parallel-collections/architecture.md | 34 +- .../concrete-parallel-collections.md | 36 +- .../parallel-collections/configuration.md | 22 +- .../parallel-collections/conversions.md | 17 +- .../overviews/parallel-collections/ctries.md | 54 +- .../custom-parallel-collections.md | 43 +- .../parallel-collections/overview.md | 6 +- .../parallel-collections/performance.md | 71 +- .../tour/abstract-types.md | 31 +- .../tour/annotations.md | 11 +- .../tour/anonymous-function-syntax.md | 13 +- .../tour/automatic-closures.md | 11 +- .../tour/case-classes.md | 11 +- .../tour/classes.md | 11 +- .../tour/compound-types.md | 11 +- .../tour/currying.md | 17 +- .../tour/default-parameter-values.md | 11 +- .../tour/explicitly-typed-self-references.md | 12 +- .../tour/extractor-objects.md | 13 +- .../tour/generic-classes.md | 11 +- .../tour/higher-order-functions.md | 17 +- _es/tour/implicit-conversions.md | 16 + .../tour/implicit-parameters.md | 13 +- .../tour/inner-classes.md | 23 +- .../tour/local-type-inference.md | 15 +- .../tour/lower-type-bounds.md | 12 +- .../tour/mixin-class-composition.md | 35 +- .../tour/named-parameters.md | 10 +- .../tour/nested-functions.md | 11 +- .../tour/operators.md | 11 +- .../tour/pattern-matching.md | 11 +- .../tour/polymorphic-methods.md | 13 +- .../tour/regular-expression-patterns.md | 11 +- .../tour/sequence-comprehensions.md | 18 +- .../tour/singleton-objects.md | 15 +- .../tour/tour-of-scala.md | 10 +- .../tour/traits.md | 21 +- .../tour/unified-types.md | 11 +- .../tour/upper-type-bounds.md | 13 +- .../tour/variances.md | 11 +- .../tutorials/scala-for-java-programmers.md | 23 +- {fr => _fr}/cheatsheets/index.md | 8 +- _includes/allsids.txt | 28 - _includes/blog-list.html | 75 + _includes/books.html | 21 + _includes/cheatsheet-header.txt | 31 +- _includes/cheatsheet-sidebar.txt | 40 - _includes/collections.txt | 4 - _includes/column-list-of-items.html | 18 + _includes/contributing-header.txt | 8 - _includes/contributing-toc.txt | 7 - _includes/contributions-projects-list.html | 36 + _includes/coursera-stats-js.txt | 21 - _includes/discourse.html | 12 + _includes/disqus.txt | 18 - _includes/download-resource-list.html | 31 + _includes/downloads-list.html | 19 + _includes/events-training-list-bottom.html | 12 + _includes/events-training-list-top.html | 73 + _includes/footer.html | 97 + _includes/footer.txt | 15 - _includes/footerbar.txt | 53 - _includes/frontpage-content.txt | 97 - _includes/frontpage-footer.txt | 6 - _includes/frontpage-header.txt | 153 - _includes/gen-toc.txt | 6 - ...ossary-header.txt => glossary-header.html} | 33 +- _includes/glossary-sidebar.txt | 6 - _includes/header-coursera.txt | 180 - _includes/header.txt | 159 - _includes/headerbottom.html | 3 + _includes/headertop.html | 25 + _includes/index-header.txt | 264 - .../inner-page-blog-detail-main-content.html | 27 + _includes/inner-page-main-content.html | 12 + _includes/localized-overview-index.txt | 34 - _includes/masthead-community.html | 37 + _includes/masthead-documentation.html | 34 + _includes/navbar-inner.html | 67 + _includes/online-courses.html | 91 + _includes/pager.txt | 8 +- _includes/paginator.html | 9 + _includes/scastie.html | 23 + _includes/search-header.txt | 267 - _includes/sidebar-toc-glossary.html | 10 + _includes/sidebar-toc-multipage-overview.html | 51 + .../sidebar-toc-singlepage-overview.html | 31 + _includes/sidebar-toc-style.html | 59 + _includes/sidebar-toc-tour-overview.html | 48 + _includes/sidebar-toc.html | 59 + _includes/sips-topbar.txt | 17 - _includes/thanks-to.txt | 14 - _includes/toc-large.txt | 28 - _includes/toc.txt | 57 - _includes/topbar.txt | 47 - _includes/tutorial-list.html | 7 + _includes/tutorial-toc.html | 29 + _includes/tutorial-toc.txt | 6 - _includes/twitter-feed.html | 15 + _includes/upcoming-training.html | 38 + _includes/worldmap.html | 0 .../tutorials/scala-for-java-programmers.md | 8 +- {ja => _ja}/cheatsheets/index.md | 9 +- {ja => _ja}/overviews/collections/arrays.md | 6 +- .../concrete-immutable-collection-classes.md | 9 +- .../concrete-mutable-collection-classes.md | 9 +- ...ions-between-java-and-scala-collections.md | 14 +- .../creating-collections-from-scratch.md | 7 +- {ja => _ja}/overviews/collections/equality.md | 13 +- .../overviews/collections/introduction.md | 9 +- .../overviews/collections/iterators.md | 9 +- {ja => _ja}/overviews/collections/maps.md | 11 +- .../collections/migrating-from-scala-27.md | 8 +- {ja => _ja}/overviews/collections/overview.md | 9 +- .../performance-characteristics.md | 7 +- {ja => _ja}/overviews/collections/seqs.md | 7 +- {ja => _ja}/overviews/collections/sets.md | 7 +- {ja => _ja}/overviews/collections/strings.md | 9 +- .../overviews/collections/trait-iterable.md | 9 +- .../collections/trait-traversable.md | 9 +- {ja => _ja}/overviews/collections/views.md | 13 +- {ja => _ja}/overviews/core/futures.md | 70 +- .../overviews/core/string-interpolation.md | 21 +- {ja => _ja}/overviews/core/value-classes.md | 12 +- {ja => _ja}/overviews/index.md | 2 +- {ja => _ja}/overviews/macros/annotations.md | 7 +- .../overviews/macros/blackbox-whitebox.md | 9 +- {ja => _ja}/overviews/macros/bundles.md | 9 +- {ja => _ja}/overviews/macros/extractors.md | 11 +- {ja => _ja}/overviews/macros/implicits.md | 12 +- {ja => _ja}/overviews/macros/inference.md | 4 +- {ja => _ja}/overviews/macros/overview.md | 11 +- {ja => _ja}/overviews/macros/paradise.md | 7 +- {ja => _ja}/overviews/macros/quasiquotes.md | 7 +- {ja => _ja}/overviews/macros/roadmap.md | 9 +- {ja => _ja}/overviews/macros/typemacros.md | 6 +- {ja => _ja}/overviews/macros/typeproviders.md | 9 +- {ja => _ja}/overviews/macros/untypedmacros.md | 4 +- {ja => _ja}/overviews/macros/usecases.md | 9 +- .../parallel-collections/architecture.md | 6 +- .../concrete-parallel-collections.md | 26 +- .../parallel-collections/configuration.md | 18 +- .../parallel-collections/conversions.md | 8 +- .../overviews/parallel-collections/ctries.md | 26 +- .../custom-parallel-collections.md | 34 +- .../parallel-collections/overview.md | 40 +- .../parallel-collections/performance.md | 32 +- .../reflection/annotations-names-scopes.md | 48 +- .../environment-universes-mirrors.md | 16 +- {ja => _ja}/overviews/reflection/overview.md | 16 +- .../reflection/symbols-trees-types.md | 20 +- .../overviews/reflection/thread-safety.md | 8 +- .../reflection/typetags-manifests.md | 9 +- .../tour/abstract-types.md | 33 +- .../tour/annotations.md | 11 +- .../tour/anonymous-function-syntax.md | 11 +- .../tour/automatic-closures.md | 11 +- .../tour/case-classes.md | 11 +- .../tour/classes.md | 11 +- .../tour/compound-types.md | 11 +- .../tour/currying.md | 11 +- .../tour/default-parameter-values.md | 11 +- .../tour/explicitly-typed-self-references.md | 11 +- .../tour/extractor-objects.md | 11 +- .../tour/generic-classes.md | 11 +- .../tour/higher-order-functions.md | 11 +- .../tour/implicit-conversions.md | 10 +- .../tour/implicit-parameters.md | 11 +- .../tour/inner-classes.md | 11 +- .../tour/local-type-inference.md | 11 +- .../tour/lower-type-bounds.md | 11 +- .../tour/mixin-class-composition.md | 19 +- .../tour/named-parameters.md | 10 +- .../tour/nested-functions.md | 11 +- .../tour/operators.md | 11 +- .../tour/pattern-matching.md | 11 +- .../tour/polymorphic-methods.md | 11 +- .../tour/regular-expression-patterns.md | 11 +- .../tour/sequence-comprehensions.md | 11 +- .../tour/singleton-objects.md | 11 +- .../tour/tour-of-scala.md | 10 +- .../tour/traits.md | 11 +- .../tour/unified-types.md | 11 +- .../tour/upper-type-bounds.md | 11 +- .../tour/variances.md | 11 +- .../tutorials/scala-for-java-programmers.md | 12 +- _layouts/blog-detail.html | 6 + _layouts/blog-list.html | 9 + _layouts/cheatsheet.html | 62 +- _layouts/contribute.html | 22 +- _layouts/default.html | 2 - _layouts/downloadpage.html | 100 + _layouts/events.html | 13 + _layouts/frontpage.html | 387 +- _layouts/glossary.html | 44 +- _layouts/guides-index.html | 43 - _layouts/guides-thanks.html | 12 - _layouts/index.html | 23 - _layouts/inner-page-community.html | 9 + _layouts/inner-page-documentation.html | 6 + _layouts/inner-page-no-masthead.html | 6 + _layouts/inner-page-parent-dropdown.html | 38 + _layouts/inner-page-parent.html | 23 + _layouts/inner-page.html | 13 + _layouts/multipage-overview.html | 18 + _layouts/news-coursera.html | 21 - _layouts/news.html | 25 - _layouts/overview-large.html | 52 - _layouts/overview.html | 76 +- _layouts/overviews.html | 13 + _layouts/page.html | 33 - _layouts/redirected.html | 16 - _layouts/search.html | 23 - _layouts/singlepage-overview.html | 17 + _layouts/sip-landing.html | 28 - _layouts/sip.html | 45 +- _layouts/sips.html | 48 + _layouts/slip.html | 23 - _layouts/style-guide.html | 18 + _layouts/tour.html | 29 + _layouts/training.html | 9 + _layouts/tutorial.html | 53 - {tutorials => _overviews}/FAQ/breakout.md | 52 +- .../FAQ/chaining-implicits.md | 7 +- {tutorials => _overviews}/FAQ/collections.md | 8 +- .../FAQ/context-bounds.md | 10 +- .../FAQ/finding-implicits.md | 22 +- .../FAQ/finding-symbols.md | 11 +- _overviews/FAQ/index.md | 22 + .../FAQ/initialization-order.md | 7 +- .../FAQ/stream-view-iterator.md | 8 +- {tutorials => _overviews}/FAQ/yield.md | 27 +- _overviews/cheatsheets/index.md | 358 + .../collections/arrays.md | 29 +- .../concrete-immutable-collection-classes.md | 32 +- .../concrete-mutable-collection-classes.md | 30 +- ...ions-between-java-and-scala-collections.md | 21 +- .../creating-collections-from-scratch.md | 8 +- .../collections/equality.md | 14 +- .../collections/introduction.md | 10 +- .../collections/iterators.md | 8 +- {overviews => _overviews}/collections/maps.md | 12 +- .../collections/migrating-from-scala-27.md | 9 +- .../collections/overview.md | 8 +- .../performance-characteristics.md | 8 +- {overviews => _overviews}/collections/seqs.md | 10 +- {overviews => _overviews}/collections/sets.md | 10 +- .../collections/strings.md | 12 +- .../collections/trait-iterable.md | 10 +- .../collections/trait-traversable.md | 12 +- .../collections/views.md | 15 +- .../core/actors-migration-guide.md | 12 +- .../core/actors.md | 9 +- .../core/architecture-of-scala-collections.md | 165 +- .../binary-compatibility-of-scala-releases.md | 15 +- .../core/futures.md | 111 +- .../core/implicit-classes.md | 30 +- .../core/string-interpolation.md | 13 +- .../core/value-classes.md | 10 +- _overviews/index.md | 44 + {overviews => _overviews}/macros.html | 4 + .../macros/annotations.md | 15 +- .../macros/blackbox-whitebox.md | 18 +- {overviews => _overviews}/macros/bundles.md | 15 +- .../macros/changelog211.md | 30 +- .../macros/extractors.md | 16 +- {overviews => _overviews}/macros/implicits.md | 15 +- {overviews => _overviews}/macros/inference.md | 8 +- {overviews => _overviews}/macros/overview.md | 19 +- {overviews => _overviews}/macros/paradise.md | 15 +- _overviews/macros/quasiquotes.md | 16 + _overviews/macros/roadmap.md | 44 + .../macros/typemacros.md | 14 +- .../macros/typeproviders.md | 17 +- .../macros/untypedmacros.md | 10 +- {overviews => _overviews}/macros/usecases.md | 11 +- .../parallel-collections/architecture.md | 10 +- .../concrete-parallel-collections.md | 99 +- .../parallel-collections/configuration.md | 22 +- .../parallel-collections/conversions.md | 13 +- .../parallel-collections/ctries.md | 32 +- .../custom-parallel-collections.md | 47 +- .../parallel-collections/overview.md | 67 +- .../parallel-collections/performance.md | 130 + .../quasiquotes/definition-details.md | 18 +- .../quasiquotes/expression-details.md | 29 +- .../quasiquotes/future.md | 11 +- .../quasiquotes/hygiene.md | 11 +- .../quasiquotes/intro.md | 26 +- .../quasiquotes/lifting.md | 17 +- .../quasiquotes/pattern-details.md | 15 +- .../quasiquotes/setup.md | 12 +- .../quasiquotes/syntax-summary.md | 129 +- .../quasiquotes/terminology.md | 20 +- .../quasiquotes/type-details.md | 27 +- .../quasiquotes/unlifting.md | 17 +- .../quasiquotes/usecases.md | 11 +- .../reflection/annotations-names-scopes.md | 52 +- _overviews/reflection/changelog211.md | 18 + .../environment-universes-mirrors.md | 17 +- .../reflection/overview.md | 17 +- .../reflection/symbols-trees-types.md | 17 +- .../reflection/thread-safety.md | 9 +- .../reflection/typetags-manifests.md | 11 +- {overviews => _overviews}/repl/embedding.md | 9 +- {overviews => _overviews}/repl/overview.md | 9 +- {overviews => _overviews}/scaladoc/basics.md | 2 +- .../scaladoc/for-library-authors.md | 13 +- .../scaladoc/interface.md | 9 +- .../scaladoc/overview.md | 15 +- {overviews => _overviews}/scaladoc/usage.md | 2 +- ...inary-compatibility-for-library-authors.md | 222 + ...scala-for-csharp-programmers.disabled.html | 2 +- .../tutorials}/scala-for-java-programmers.md | 16 +- .../tutorials}/scala-with-maven.md | 5 +- {pl => _pl}/cheatsheets/index.md | 8 +- .../tour/abstract-types.md | 26 +- .../tour/annotations.md | 12 +- .../tour/anonymous-function-syntax.md | 12 +- .../tour/automatic-closures.md | 12 +- .../tour/case-classes.md | 12 +- .../tour/classes.md | 12 +- .../tour/compound-types.md | 12 +- .../tour/currying.md | 12 +- .../tour/default-parameter-values.md | 12 +- .../tour/explicitly-typed-self-references.md | 12 +- .../tour/extractor-objects.md | 12 +- .../tour/generic-classes.md | 12 +- .../tour/higher-order-functions.md | 12 +- .../tour/implicit-conversions.md | 12 +- .../tour/implicit-parameters.md | 12 +- .../tour/inner-classes.md | 12 +- .../tour/local-type-inference.md | 12 +- .../tour/lower-type-bounds.md | 12 +- .../tour/mixin-class-composition.md | 20 +- .../tour/named-parameters.md | 10 +- .../tour/nested-functions.md | 12 +- .../tour/operators.md | 12 +- .../tour/pattern-matching.md | 12 +- .../tour/polymorphic-methods.md | 12 +- .../tour/regular-expression-patterns.md | 12 +- .../tour/sequence-comprehensions.md | 12 +- .../tour/singleton-objects.md | 12 +- .../tour/tour-of-scala.md | 10 +- .../tour/traits.md | 12 +- .../tour/unified-types.md | 12 +- .../tour/upper-type-bounds.md | 12 +- .../tour/variances.md | 12 +- _plugins/tut_replace.rb | 20 + {pt-br => _pt-br}/cheatsheets/index.md | 8 +- .../tour/abstract-types.md | 15 +- .../tour/annotations.md | 12 +- .../tour/anonymous-function-syntax.md | 12 +- .../tour/automatic-closures.md | 12 +- .../tour/case-classes.md | 12 +- .../tour/classes.md | 12 +- .../tour/compound-types.md | 12 +- .../tour/currying.md | 12 +- .../tour/default-parameter-values.md | 12 +- .../tour/explicitly-typed-self-references.md | 12 +- .../tour/extractor-objects.md | 12 +- .../tour/generic-classes.md | 12 +- .../tour/higher-order-functions.md | 12 +- .../tour/implicit-conversions.md | 12 +- .../tour/implicit-parameters.md | 12 +- .../tour/inner-classes.md | 12 +- .../tour/local-type-inference.md | 12 +- .../tour/lower-type-bounds.md | 12 +- .../tour/mixin-class-composition.md | 22 +- .../tour/named-parameters.md | 10 +- .../tour/nested-functions.md | 12 +- .../tour/operators.md | 12 +- .../tour/pattern-matching.md | 12 +- .../tour/polymorphic-methods.md | 12 +- .../tour/regular-expression-patterns.md | 12 +- .../tour/sequence-comprehensions.md | 12 +- .../tour/singleton-objects.md | 14 +- .../tour/tour-of-scala.md | 12 +- .../tour/traits.md | 12 +- .../tour/unified-types.md | 12 +- .../tour/upper-type-bounds.md | 12 +- .../tour/variances.md | 12 +- .../parallel-collections/architecture.md | 10 +- .../concrete-parallel-collections.md | 25 +- .../parallel-collections/configuration.md | 18 +- .../parallel-collections/conversions.md | 6 +- .../overviews/parallel-collections/ctries.md | 32 +- .../custom-parallel-collections.md | 44 +- .../parallel-collections/overview.md | 47 +- .../parallel-collections/performance.md | 42 +- _sass/base/body.scss | 18 + _sass/base/form.scss | 30 + _sass/base/helper.scss | 14 + _sass/base/lists.scss | 22 + _sass/base/media.scss | 12 + _sass/base/typography.scss | 62 + _sass/components/buttons.scss | 22 + _sass/components/calendar.scss | 33 + _sass/components/call-to-action.scss | 39 + _sass/components/card.scss | 60 + _sass/components/code.scss | 25 + _sass/components/dropdown.scss | 162 + _sass/components/heading-line.scss | 52 + _sass/components/pagination.scss | 33 + _sass/components/search.scss | 54 + _sass/components/slider.scss | 35 + _sass/components/tab.scss | 43 + _sass/components/tag.scss | 20 + _sass/components/tooltip.scss | 13 + _sass/layout/blog.scss | 113 + _sass/layout/books.scss | 89 + _sass/layout/cheatsheet.scss | 55 + _sass/layout/courses.scss | 31 + _sass/layout/doc-navigation.scss | 130 + _sass/layout/documentation.scss | 59 + _sass/layout/download.scss | 250 + _sass/layout/footer.scss | 76 + _sass/layout/glossary.scss | 75 + _sass/layout/header.scss | 111 + _sass/layout/ides.scss | 81 + _sass/layout/inner-main.scss | 178 + _sass/layout/inner-text.scss | 28 + _sass/layout/maintenance.scss | 89 + _sass/layout/marker.scss | 64 + _sass/layout/navigation.scss | 94 + _sass/layout/new-blog.scss | 154 + _sass/layout/nutshell.scss | 111 + _sass/layout/overviews.scss | 184 + _sass/layout/run-scala.scss | 57 + _sass/layout/runs.scss | 71 + _sass/layout/scala-ecosystem.scss | 125 + _sass/layout/scala-main-resources.scss | 181 + _sass/layout/scaladex.scss | 10 + _sass/layout/sips.scss | 201 + _sass/layout/site-main.scss | 26 + _sass/layout/style-guide.scss | 23 + _sass/layout/table-of-content.scss | 199 + _sass/layout/talk-to-us.scss | 197 + _sass/layout/title-page.scss | 17 + _sass/layout/toc.scss | 59 + _sass/layout/tools.scss | 66 + _sass/layout/training-events.scss | 82 + _sass/layout/twitter-feed.scss | 140 + _sass/layout/type-md.scss | 214 + _sass/layout/upcoming-events.scss | 31 + _sass/utils/_mixins.scss | 93 + _sass/utils/_variables.scss | 94 + .../bourbon/_bourbon-deprecated-upcoming.scss | 411 + _sass/vendors/bourbon/_bourbon.scss | 87 + .../vendors/bourbon/addons/_border-color.scss | 26 + .../bourbon/addons/_border-radius.scss | 48 + .../vendors/bourbon/addons/_border-style.scss | 25 + .../vendors/bourbon/addons/_border-width.scss | 25 + _sass/vendors/bourbon/addons/_buttons.scss | 64 + _sass/vendors/bourbon/addons/_clearfix.scss | 25 + _sass/vendors/bourbon/addons/_ellipsis.scss | 30 + .../vendors/bourbon/addons/_font-stacks.scss | 31 + _sass/vendors/bourbon/addons/_hide-text.scss | 27 + _sass/vendors/bourbon/addons/_margin.scss | 26 + _sass/vendors/bourbon/addons/_padding.scss | 26 + _sass/vendors/bourbon/addons/_position.scss | 48 + _sass/vendors/bourbon/addons/_prefixer.scss | 66 + .../vendors/bourbon/addons/_retina-image.scss | 25 + _sass/vendors/bourbon/addons/_size.scss | 51 + .../vendors/bourbon/addons/_text-inputs.scss | 113 + .../bourbon/addons/_timing-functions.scss | 34 + _sass/vendors/bourbon/addons/_triangle.scss | 63 + _sass/vendors/bourbon/addons/_word-wrap.scss | 29 + _sass/vendors/bourbon/css3/_animation.scss | 43 + _sass/vendors/bourbon/css3/_appearance.scss | 3 + .../bourbon/css3/_backface-visibility.scss | 3 + .../bourbon/css3/_background-image.scss | 42 + _sass/vendors/bourbon/css3/_background.scss | 55 + _sass/vendors/bourbon/css3/_border-image.scss | 59 + _sass/vendors/bourbon/css3/_calc.scss | 4 + _sass/vendors/bourbon/css3/_columns.scss | 47 + _sass/vendors/bourbon/css3/_filter.scss | 4 + _sass/vendors/bourbon/css3/_flex-box.scss | 287 + _sass/vendors/bourbon/css3/_font-face.scss | 24 + .../bourbon/css3/_font-feature-settings.scss | 4 + .../bourbon/css3/_hidpi-media-query.scss | 10 + _sass/vendors/bourbon/css3/_hyphens.scss | 4 + .../bourbon/css3/_image-rendering.scss | 14 + _sass/vendors/bourbon/css3/_keyframes.scss | 36 + .../bourbon/css3/_linear-gradient.scss | 38 + _sass/vendors/bourbon/css3/_perspective.scss | 8 + _sass/vendors/bourbon/css3/_placeholder.scss | 8 + .../bourbon/css3/_radial-gradient.scss | 39 + _sass/vendors/bourbon/css3/_selection.scss | 42 + .../bourbon/css3/_text-decoration.scss | 19 + _sass/vendors/bourbon/css3/_transform.scss | 15 + _sass/vendors/bourbon/css3/_transition.scss | 71 + _sass/vendors/bourbon/css3/_user-select.scss | 3 + .../bourbon/functions/_assign-inputs.scss | 11 + .../bourbon/functions/_contains-falsy.scss | 20 + .../vendors/bourbon/functions/_contains.scss | 26 + .../vendors/bourbon/functions/_is-length.scss | 11 + .../vendors/bourbon/functions/_is-light.scss | 21 + .../vendors/bourbon/functions/_is-number.scss | 11 + _sass/vendors/bourbon/functions/_is-size.scss | 13 + .../bourbon/functions/_modular-scale.scss | 69 + .../vendors/bourbon/functions/_px-to-em.scss | 13 + .../vendors/bourbon/functions/_px-to-rem.scss | 15 + _sass/vendors/bourbon/functions/_shade.scss | 24 + .../bourbon/functions/_strip-units.scss | 17 + _sass/vendors/bourbon/functions/_tint.scss | 24 + .../functions/_transition-property-name.scss | 22 + _sass/vendors/bourbon/functions/_unpack.scss | 27 + .../bourbon/helpers/_convert-units.scss | 21 + .../bourbon/helpers/_directional-values.scss | 96 + .../helpers/_font-source-declaration.scss | 43 + .../helpers/_gradient-positions-parser.scss | 13 + .../bourbon/helpers/_linear-angle-parser.scss | 25 + .../helpers/_linear-gradient-parser.scss | 41 + .../helpers/_linear-positions-parser.scss | 61 + .../helpers/_linear-side-corner-parser.scss | 31 + .../bourbon/helpers/_radial-arg-parser.scss | 69 + .../helpers/_radial-gradient-parser.scss | 50 + .../helpers/_radial-positions-parser.scss | 18 + .../bourbon/helpers/_render-gradients.scss | 26 + .../bourbon/helpers/_shape-size-stripper.scss | 10 + .../vendors/bourbon/helpers/_str-to-num.scss | 50 + .../bourbon/settings/_asset-pipeline.scss | 7 + _sass/vendors/bourbon/settings/_prefixer.scss | 9 + _sass/vendors/bourbon/settings/_px-to-em.scss | 1 + _sass/vendors/neat/_neat-helpers.scss | 11 + _sass/vendors/neat/_neat.scss | 23 + .../neat/functions/_new-breakpoint.scss | 49 + _sass/vendors/neat/functions/_private.scss | 114 + _sass/vendors/neat/grid/_box-sizing.scss | 15 + .../vendors/neat/grid/_direction-context.scss | 33 + _sass/vendors/neat/grid/_display-context.scss | 28 + _sass/vendors/neat/grid/_fill-parent.scss | 22 + _sass/vendors/neat/grid/_media.scss | 92 + _sass/vendors/neat/grid/_omega.scss | 87 + _sass/vendors/neat/grid/_outer-container.scss | 34 + _sass/vendors/neat/grid/_pad.scss | 25 + _sass/vendors/neat/grid/_private.scss | 35 + _sass/vendors/neat/grid/_row.scss | 52 + _sass/vendors/neat/grid/_shift.scss | 50 + _sass/vendors/neat/grid/_span-columns.scss | 94 + _sass/vendors/neat/grid/_to-deprecate.scss | 97 + _sass/vendors/neat/grid/_visual-grid.scss | 42 + _sass/vendors/neat/mixins/_clearfix.scss | 25 + .../neat/settings/_disable-warnings.scss | 13 + _sass/vendors/neat/settings/_grid.scss | 51 + _sass/vendors/neat/settings/_visual-grid.scss | 27 + _sass/vendors/unslider/unslider.scss | 8 + _sass/vendors/unslider/unslider/dots.scss | 30 + _sass/vendors/unslider/unslider/reset.scss | 70 + _sass/vendors/unslider/variables.scss | 18 + _sips/README.md | 3 + _sips/all.md | 55 + _sips/index.md | 51 + _sips/minutes-list.md | 17 + .../minutes}/2016-07-15-sip-minutes.md | 6 +- .../2016-08-16-sip-10th-august-minutes.md | 8 +- .../2016-09-20-sip-20th-september-minutes.md | 10 +- .../minutes}/2016-10-25-sip-minutes.md | 10 +- .../minutes}/2016-11-29-sip-minutes.md | 10 +- _sips/minutes/2017-02-14-sip-minutes.md | 262 + _sips/minutes/2017-05-08-sip-minutes.md | 93 + _sips/minutes/2017-09-21-sip-minutes.md | 104 + _sips/minutes/2017-10-24-sip-minutes.md | 229 + _sips/minutes/2017-12-06-sip-minutes.md | 116 + .../minutes/_posts/2017-02-14-sip-minutes.md | 260 + {sips => _sips}/sip-submission.md | 18 +- {sips => _sips}/sip-template.md | 4 +- {sips => _sips}/sip-tutorial.md | 10 +- ...09-05-28-scala-compiler-phase-plugin-in.md | 6 +- .../2009-06-02-early-member-definitions.md | 9 + .../sips}/2009-11-02-scala-swing-overview.md | 3 + .../2010-01-22-named-and-default-arguments.md | 7 +- .../sips}/2010-01-22-scala-2-8-arrays.md | 51 +- ...10-01-27-internals-of-scala-annotations.md | 5 +- _sips/sips/2010-05-06-scala-specialization.md | 9 + .../sips}/2010-06-01-picked-signatures.md | 5 +- .../sips/2010-07-20-new-collection-classes.md | 9 + .../sips}/2011-10-12-implicit-classes.md | 11 +- _sips/sips/2011-10-13-string-interpolation.md | 17 + .../sips}/2011-10-13-uncluttering-control.md | 9 +- .../sips}/2012-01-21-futures-promises.md | 88 +- .../sips}/2012-01-30-value-classes.md | 35 +- .../sips}/2012-03-09-self-cleaning-macros.md | 5 +- .../sips}/2012-03-13-type-dynamic.md | 11 +- ...12-03-17-modularizing-language-features.md | 11 +- .../sips}/2012-03-30-source-locations.md | 10 +- ...-05-31-improved-lazy-val-initialization.md | 17 +- .../sips}/2013-06-10-spores.md | 7 +- .../_posts => _sips/sips}/2013-06-30-async.md | 10 +- _sips/sips/2014-06-27-42.type.md | 694 ++ .../sips}/2015-6-18-repeated-byname.md | 4 +- .../sips}/2015-6-18-trait-parameters.md | 5 +- .../sips}/2016-01-11-static-members.md | 39 +- .../sips}/2016-06-25-trailing-commas.md | 17 +- .../sips}/2016-07-25-unsigned-integers.md | 3 +- .../sips}/2016-09-09-inline-meta.md | 7 +- ...017-01-11-refer-other-arguments-in-args.md | 7 +- .../sips}/2017-01-13-binary-compatibility.md | 135 +- ...07-priority-based-infix-type-precedence.md | 153 + .../2017-02-22-comonadic-comprehensions.md | 45 +- ...-12-right-associative-by-name-operators.md | 93 + _sips/sips/2017-09-20-opaque-types.md | 802 ++ _sips/sips/2017-10-25-adding-prefix-types.md | 195 + {style => _style}/control-structures.md | 6 +- {style => _style}/declarations.md | 10 +- {style => _style}/files.md | 6 +- {style => _style}/indentation.md | 6 +- _style/index.md | 75 + {style => _style}/method-invocation.md | 6 +- {style => _style}/naming-conventions.md | 6 +- {style => _style}/nested-blocks.md | 6 +- {style => _style}/overview.md | 7 +- {style => _style}/scaladoc.md | 72 +- {style => _style}/types.md | 6 +- .../abstract-types.md | 12 +- .../annotations.md | 12 +- .../2017-02-13-basics.md => _tour/basics.md | 14 +- .../by-name-parameters.md | 14 +- .../case-classes.md | 14 +- .../2017-02-13-classes.md => _tour/classes.md | 12 +- .../compound-types.md | 16 +- .../currying.md | 10 +- .../default-parameter-values.md | 10 +- {tutorials/tour => _tour}/dot-hot-reload.sh | 0 .../extractor-objects.md | 14 +- _tour/for-comprehensions.md | 66 + .../generic-classes.md | 12 +- _tour/higher-order-functions.md | 125 + .../implicit-conversions.md | 10 +- _tour/implicit-parameters.md | 65 + .../inner-classes.md | 10 +- .../local-type-inference.md | 11 +- .../lower-type-bounds.md | 25 +- _tour/mixin-class-composition.md | 83 + .../named-arguments.md | 23 +- .../nested-functions.md | 12 +- .../operators.md | 12 +- _tour/packages-and-imports.md | 84 + .../pattern-matching.md | 12 +- _tour/polymorphic-methods.md | 36 + .../regular-expression-patterns.md | 12 +- .../self-types.md | 16 +- .../singleton-objects.md | 14 +- _tour/tour-of-scala.md | 46 + .../2017-02-13-traits.md => _tour/traits.md | 22 +- .../unified-types.md | 16 +- .../upper-type-bounds.md | 10 +- .../variances.md | 19 +- _zh-cn/cheatsheets/index.md | 89 + _zh-cn/overviews/collections/arrays.md | 34 +- .../concrete-immutable-collection-classes.md | 17 +- .../concrete-mutable-collection-classes.md | 13 +- ...ions-between-java-and-scala-collections.md | 13 +- .../creating-collections-from-scratch.md | 9 +- _zh-cn/overviews/collections/equality.md | 12 +- _zh-cn/overviews/collections/introduction.md | 7 +- _zh-cn/overviews/collections/iterators.md | 18 +- _zh-cn/overviews/collections/maps.md | 25 +- .../collections/migrating-from-scala-27.md | 9 +- _zh-cn/overviews/collections/overview.md | 16 +- .../performance-characteristics.md | 7 +- _zh-cn/overviews/collections/seqs.md | 7 +- _zh-cn/overviews/collections/sets.md | 17 +- _zh-cn/overviews/collections/strings.md | 8 +- .../overviews/collections/trait-iterable.md | 23 +- .../collections/trait-traversable.md | 7 +- _zh-cn/overviews/collections/views.md | 16 +- .../overviews/core/actors-migration-guide.md | 84 +- _zh-cn/overviews/core/actors.md | 18 +- .../core/architecture-of-scala-collections.md | 9 +- _zh-cn/overviews/core/futures.md | 92 +- _zh-cn/overviews/core/implicit-classes.md | 21 +- _zh-cn/overviews/core/string-interpolation.md | 32 +- _zh-cn/overviews/core/value-classes.md | 14 +- .../parallel-collections/architecture.md | 6 +- .../concrete-parallel-collections.md | 6 +- .../parallel-collections/configuration.md | 23 +- .../parallel-collections/conversions.md | 11 +- .../overviews/parallel-collections/ctries.md | 29 +- .../custom-parallel-collections.md | 61 +- .../parallel-collections/overview.md | 50 +- _zh-cn/thanks.md | 47 + .../tutorials/scala-for-java-programmers.md | 8 +- api/all.md | 150 + .../tour/_posts/2017-02-13-abstract-types.md | 83 - .../tour/_posts/2017-02-13-annotations.md | 131 - .../2017-02-13-anonymous-function-syntax.md | 42 - .../_posts/2017-02-13-automatic-closures.md | 80 - .../tour/_posts/2017-02-13-case-classes.md | 90 - .../tour/_posts/2017-02-13-classes.md | 58 - .../tour/_posts/2017-02-13-currying.md | 40 - .../2017-02-13-default-parameter-values.md | 73 - ...-02-13-explicitly-typed-self-references.md | 124 - .../_posts/2017-02-13-extractor-objects.md | 54 - .../tour/_posts/2017-02-13-generic-classes.md | 49 - .../_posts/2017-02-13-implicit-parameters.md | 52 - .../tour/_posts/2017-02-13-inner-classes.md | 99 - .../_posts/2017-02-13-lower-type-bounds.md | 59 - .../2017-02-13-mixin-class-composition.md | 56 - .../_posts/2017-02-13-named-parameters.md | 37 - .../_posts/2017-02-13-nested-functions.md | 32 - .../tour/_posts/2017-02-13-operators.md | 35 - .../_posts/2017-02-13-pattern-matching.md | 47 - .../_posts/2017-02-13-polymorphic-methods.md | 33 - .../2017-02-13-regular-expression-patterns.md | 48 - .../2017-02-13-sequence-comprehensions.md | 70 - ba/tutorials/tour/_posts/2017-02-13-traits.md | 52 - .../tour/_posts/2017-02-13-unified-types.md | 58 - .../_posts/2017-02-13-upper-type-bounds.md | 38 - .../tour/_posts/2017-02-13-variances.md | 60 - books.md | 13 + cheatsheets/index.md | 85 - conduct.html | 2 +- contribute.md | 18 +- .../_posts/2017-02-13-polymorphic-methods.md | 37 - es/overviews/core/parallel-collections.md | 7 - es/overviews/index.md | 14 - .../_posts/2017-02-13-implicit-conversions.md | 13 - ...g-a-scala-project-with-intellij-and-sbt.md | 106 + .../getting-started-with-scala-in-intellij.md | 76 + ...esting-scala-in-intellij-with-scalatest.md | 78 + ...-with-scala-and-sbt-on-the-command-line.md | 88 + ...ting-scala-with-sbt-on-the-command-line.md | 74 + getting-started.md | 61 + glossary/index.md | 77 +- guides.md | 6 + index.md | 69 +- ja/overviews/core/collections.md | 7 - ja/overviews/core/macros.md | 9 - ja/overviews/core/parallel-collections.md | 7 - ja/overviews/core/reflection.md | 9 - learn.md | 32 + ...les-in-scala-impressions-and-statistics.md | 7 +- .../core/_posts/2010-09-07-collections.md | 8 - .../_posts/2012-03-27-parallel-collections.md | 8 - overviews/core/_posts/2012-12-20-macros.md | 10 - .../core/_posts/2013-01-02-reflection.md | 10 - overviews/index.md | 84 - overviews/macros/quasiquotes.md | 13 - overviews/macros/roadmap.md | 41 - overviews/parallel-collections/performance.md | 284 - overviews/reflection/changelog211.md | 14 - reference.md | 6 + resources/{stylesheets => css}/bootstrap.css | 0 resources/css/highlightjs.css | 102 + resources/css/monospace.css | 42 + resources/css/prettify.css | 29 + resources/{stylesheets => css}/search.css | 0 resources/css/style.scss | 72 + resources/css/unslider-dots.css | 33 + resources/css/unslider.css | 1 + resources/css/vendor/codemirror.css | 347 + resources/css/vendor/monokai.css | 36 + resources/glyphs/Consolas-Bold.eot | Bin 0 -> 97182 bytes resources/glyphs/Consolas-Bold.ttf | Bin 0 -> 97008 bytes resources/glyphs/Consolas-Bold.woff | Bin 0 -> 59492 bytes resources/glyphs/Consolas-BoldItalic.eot | Bin 0 -> 107150 bytes resources/glyphs/Consolas-BoldItalic.ttf | Bin 0 -> 106948 bytes resources/glyphs/Consolas-BoldItalic.woff | Bin 0 -> 66592 bytes resources/glyphs/Consolas-Italic.eot | Bin 0 -> 101014 bytes resources/glyphs/Consolas-Italic.ttf | Bin 0 -> 100832 bytes resources/glyphs/Consolas-Italic.woff | Bin 0 -> 63412 bytes resources/glyphs/Consolas.eot | Bin 0 -> 95274 bytes resources/glyphs/Consolas.ttf | Bin 0 -> 95104 bytes resources/glyphs/Consolas.woff | Bin 0 -> 58472 bytes .../library-author-guide/after_update.png | Bin 0 -> 5030 bytes .../backwards_forwards_compatibility.plantuml | 10 + .../library-author-guide/before_update.png | Bin 0 -> 4892 bytes .../dependency_hell.plantuml | 25 + .../library-author-guide/dependency_hell.png | Bin 0 -> 12927 bytes .../fowards_backwards_compatibility.png | Bin 0 -> 3275 bytes {tutorials => resources/images}/tour/Makefile | 0 .../images}/tour/type-casting-diagram.dot | 0 .../images}/tour/type-casting-diagram.svg | 0 .../images}/tour/unified-types-diagram.dot | 0 .../images}/tour/unified-types-diagram.svg | 0 {tutorials => resources/img}/01-post.png | Bin {tutorials => resources/img}/02-post.png | Bin {tutorials => resources/img}/03-fork.png | Bin {tutorials => resources/img}/04-submit.png | Bin {tutorials => resources/img}/05-review.png | Bin resources/img/bee-scala.png | Bin 0 -> 1859 bytes resources/img/bee-scala@2x.png | Bin 0 -> 4381 bytes resources/img/black-topo-pattern.jpg | Bin 0 -> 22889 bytes .../blog/scaladex/head-project-background.png | Bin 0 -> 117809 bytes resources/img/blog/scastie/scastie.png | Bin 0 -> 57460 bytes resources/img/blue-overlay.png | Bin 0 -> 930 bytes resources/img/books.png | Bin 0 -> 1271 bytes resources/img/books/BeginningScala.gif | Bin 0 -> 5172 bytes resources/img/books/FPiS_93x116.png | Bin 0 -> 127494 bytes resources/img/books/Pol_89x116.png | Bin 0 -> 13786 bytes resources/img/books/ProgScalaJP.gif | Bin 0 -> 6712 bytes resources/img/books/ProgrammingInScala.gif | Bin 0 -> 11492 bytes .../books/ProgrammingScala-final-border.gif | Bin 0 -> 5574 bytes resources/img/books/ProgrammingScala.gif | Bin 0 -> 5451 bytes resources/img/books/ProgrammingScala.jpg | Bin 0 -> 42408 bytes resources/img/books/Scala_in_Action.jpg | Bin 0 -> 36775 bytes resources/img/books/Umsteiger.png | Bin 0 -> 10447 bytes .../books/buildingRecommendationEngine.jpg | Bin 0 -> 21936 bytes resources/img/books/heiko_117x82.jpg | Bin 0 -> 32893 bytes .../img/books/icon_Scala_in_Action_93x116.png | Bin 0 -> 18118 bytes .../img/books/icon_Scala_in_Depth_93x116.png | Bin 0 -> 172115 bytes .../img/books/icon_funkt_Grundkurs_91x115.png | Bin 0 -> 9076 bytes resources/img/books/icon_hanser_90x113.png | Bin 0 -> 9444 bytes ...rningConcurrentProgrammingCover120x149.jpg | Bin 0 -> 51881 bytes resources/img/books/puzzlersCover117x89.gif | Bin 0 -> 3590 bytes resources/img/books/scala-puzzlers-book.jpg | Bin 0 -> 13043 bytes resources/img/books/scalaForDataScience.jpg | Bin 0 -> 19581 bytes .../img/books/scala_for_the_impatient.png | Bin 0 -> 182723 bytes resources/img/books/steps-v2.gif | Bin 0 -> 10851 bytes resources/img/books/swedish_86x115.png | Bin 0 -> 16280 bytes resources/img/books@2x.png | Bin 0 -> 1669 bytes resources/img/carousel-bg.png | Bin 0 -> 5336 bytes resources/img/code-mesh.png | Bin 0 -> 3425 bytes resources/img/code-mesh@2x.png | Bin 0 -> 6627 bytes resources/img/cufp.png | Bin 0 -> 2644 bytes resources/img/cufp@2x.png | Bin 0 -> 2505 bytes resources/img/curryon.png | Bin 0 -> 2702 bytes resources/img/curryon@2x.png | Bin 0 -> 5928 bytes resources/img/data-day.png | Bin 0 -> 2993 bytes resources/img/data-day@2x.png | Bin 0 -> 4989 bytes resources/img/date-icon.png | Bin 0 -> 1336 bytes resources/img/date-icon@2x.png | Bin 0 -> 1754 bytes resources/img/devoxx.png | Bin 0 -> 3361 bytes resources/img/devoxx@2x.png | Bin 0 -> 7683 bytes resources/img/diamond.png | Bin 0 -> 1662 bytes resources/img/documentation-logo.png | Bin 0 -> 1847 bytes resources/img/documentation-logo@2x.png | Bin 0 -> 3019 bytes resources/img/dot-grid.png | Bin 0 -> 1267 bytes resources/img/dot-grid2.png | Bin 0 -> 1269 bytes resources/img/dot-grid3.png | Bin 0 -> 1269 bytes resources/img/dot-grid4.png | Bin 0 -> 1270 bytes resources/img/download.png | Bin 0 -> 2480 bytes resources/img/download/arrow-asset.png | Bin 0 -> 2562 bytes resources/img/download/arrow-left.png | Bin 0 -> 8806 bytes resources/img/download/arrow-right.png | Bin 0 -> 8977 bytes resources/img/epfl-bc.jpg | Bin 0 -> 238843 bytes resources/img/epfl-logo.png | Bin 0 -> 3848 bytes resources/img/epfl-logo@2x.png | Bin 0 -> 8096 bytes resources/img/fby.png | Bin 0 -> 1886 bytes resources/img/flatmap-oslo-17.png | Bin 0 -> 1967 bytes resources/img/flatmap-oslo-17@2x.png | Bin 0 -> 2875 bytes resources/img/flatmap-oslo-new.png | Bin 0 -> 350 bytes resources/img/flatmap-oslo-new@2x.png | Bin 0 -> 580 bytes resources/img/flatmap-oslo.png | Bin 0 -> 1615 bytes resources/img/flatmap-oslo@2x.png | Bin 0 -> 2740 bytes resources/img/fp-exchange.png | Bin 0 -> 3654 bytes resources/img/fp-exchange@2x.png | Bin 0 -> 8426 bytes resources/img/frontpage/47deg-logo.png | Bin 0 -> 2870 bytes resources/img/frontpage/arrow.png | Bin 0 -> 494 bytes resources/img/frontpage/atom.png | Bin 0 -> 5024 bytes .../img/frontpage/avatar-twitter-feed.jpg | Bin 0 -> 9979 bytes .../img/frontpage/background-header-home.jpg | Bin 0 -> 273953 bytes .../frontpage/background-scala-ecosystem.png | Bin 0 -> 137264 bytes resources/img/frontpage/background.png | Bin 0 -> 559 bytes resources/img/frontpage/beta.png | Bin 0 -> 1076 bytes resources/img/frontpage/button-github.png | Bin 0 -> 3066 bytes resources/img/frontpage/company-logo.png | Bin 0 -> 4584 bytes resources/img/frontpage/coursera-icon.png | Bin 0 -> 1391 bytes resources/img/frontpage/discourse-logo.png | Bin 0 -> 3525 bytes resources/img/frontpage/eclipse.png | Bin 0 -> 3490 bytes resources/img/frontpage/edx-icon.png | Bin 0 -> 2015 bytes resources/img/frontpage/ensime.png | Bin 0 -> 3178 bytes resources/img/frontpage/epfl-bc.jpg | Bin 0 -> 238843 bytes resources/img/frontpage/epfl-logo.png | Bin 0 -> 7025 bytes resources/img/frontpage/gitter-logo.png | Bin 0 -> 523 bytes resources/img/frontpage/goldman-logo.png | Bin 0 -> 6815 bytes resources/img/frontpage/ibm-logo.png | Bin 0 -> 3480 bytes resources/img/frontpage/icon-ensime.png | Bin 0 -> 786 bytes resources/img/frontpage/intelliJ.png | Bin 0 -> 1319 bytes resources/img/frontpage/java-logo.png | Bin 0 -> 3875 bytes resources/img/frontpage/js-logo.png | Bin 0 -> 2100 bytes resources/img/frontpage/lightbend-logo.png | Bin 0 -> 7320 bytes resources/img/frontpage/nitro-logo.png | Bin 0 -> 6978 bytes resources/img/frontpage/sap-logo.png | Bin 0 -> 4311 bytes resources/img/frontpage/scala-logo-white.png | Bin 0 -> 2361 bytes .../img/frontpage/scala-logo-white@2x.png | Bin 0 -> 5130 bytes resources/img/frontpage/scala-spiral.png | Bin 0 -> 80003 bytes resources/img/frontpage/scalacenter-logo.png | Bin 0 -> 11171 bytes resources/img/frontpage/scaladex-logo.png | Bin 0 -> 4886 bytes resources/img/frontpage/sublime.png | Bin 0 -> 2103 bytes resources/img/frontpage/tapad-logo.png | Bin 0 -> 3272 bytes resources/img/frontpage/verizon-logo.png | Bin 0 -> 5908 bytes resources/img/funcconf.png | Bin 0 -> 3352 bytes resources/img/funcconf@2x.png | Bin 0 -> 10952 bytes resources/img/gears.png | Bin 0 -> 1203 bytes resources/img/gears@2x.png | Bin 0 -> 1538 bytes resources/img/github-logo.png | Bin 0 -> 1249 bytes resources/img/github-logo@2x.png | Bin 0 -> 1753 bytes resources/img/glyphicons-halflings-white.png | Bin 0 -> 4352 bytes resources/img/glyphicons-halflings.png | Bin 0 -> 4352 bytes resources/img/gray-line.png | Bin 0 -> 923 bytes resources/img/gsoc-2014-scala-logo.png | Bin 0 -> 2145 bytes resources/img/hof-code.png | Bin 0 -> 104574 bytes resources/img/hof-code1.png | Bin 0 -> 90013 bytes resources/img/hof-code2.png | Bin 0 -> 52583 bytes resources/img/icfp.png | Bin 0 -> 2416 bytes resources/img/icfp@2x.png | Bin 0 -> 4610 bytes resources/img/icon-announcement.png | Bin 0 -> 1379 bytes resources/img/icon-dsls.png | Bin 0 -> 3791 bytes resources/img/icon-functions.png | Bin 0 -> 4130 bytes resources/img/icon-immutability.png | Bin 0 -> 5072 bytes resources/img/icon-implicits.png | Bin 0 -> 3771 bytes resources/img/icon-java-interop.png | Bin 0 -> 4755 bytes .../img/icon-parallelism-distribution.png | Bin 0 -> 7313 bytes resources/img/icon-pattern-matching.png | Bin 0 -> 9251 bytes resources/img/icon-traits.png | Bin 0 -> 4838 bytes resources/img/icon-type-inference.png | Bin 0 -> 5534 bytes resources/img/img-overlay.png | Bin 0 -> 118 bytes resources/img/katsconf.png | Bin 0 -> 3080 bytes resources/img/katsconf@2x.png | Bin 0 -> 8997 bytes resources/img/lac-leman.jpg | Bin 0 -> 1157834 bytes resources/img/lambda-days.png | Bin 0 -> 2998 bytes resources/img/lambda-days2.png | Bin 0 -> 2002 bytes resources/img/lambda-days2@2x.png | Bin 0 -> 3466 bytes resources/img/lambda-days@2x.png | Bin 0 -> 4599 bytes resources/img/lambda-jam.png | Bin 0 -> 3040 bytes resources/img/lambda-jam@2x.png | Bin 0 -> 7086 bytes resources/img/lambda-world.png | Bin 0 -> 1302 bytes resources/img/lambda-world@2x.png | Bin 0 -> 2715 bytes resources/img/lambdaconf.png | Bin 0 -> 2058 bytes resources/img/lambdaconf@2x.png | Bin 0 -> 4546 bytes resources/img/list.png | Bin 0 -> 1013 bytes resources/img/list@2x.png | Bin 0 -> 1075 bytes resources/img/logos/Apple_logo.png | Bin 0 -> 4960 bytes resources/img/logos/Apple_logo_black.png | Bin 0 -> 736 bytes resources/img/logos/Apple_logo_black.svg | 26 + resources/img/logos/Bsd_daemon.png | Bin 0 -> 3440 bytes resources/img/logos/Bsd_daemon.svg | 146 + resources/img/logos/Bsd_daemon_BW.png | Bin 0 -> 1817 bytes resources/img/logos/Cygwin_logo.png | Bin 0 -> 787 bytes resources/img/logos/Cygwin_logo.svg | 69 + resources/img/logos/Tux.png | Bin 0 -> 2578 bytes resources/img/logos/Tux.svg | 4221 ++++++++ resources/img/logos/Tux_BW.png | Bin 0 -> 1272 bytes resources/img/logos/Windows_logo.png | Bin 0 -> 3245 bytes resources/img/logos/Windows_logo.svg | 363 + resources/img/logos/Windows_logo_BW.png | Bin 0 -> 1937 bytes resources/img/nescala-logo.png | Bin 0 -> 3297 bytes resources/img/nescala.png | Bin 0 -> 9730 bytes resources/img/nescala@2x.png | Bin 0 -> 7777 bytes resources/img/patmat-code.png | Bin 0 -> 73984 bytes resources/img/pdf-red.png | Bin 0 -> 1211 bytes resources/img/pdf-red@2x.png | Bin 0 -> 1533 bytes resources/img/pdf.png | Bin 0 -> 1049 bytes resources/img/pdf@2x.png | Bin 0 -> 1220 bytes resources/img/phillyete2014.png | Bin 0 -> 2814 bytes resources/img/phillyete2014@2x.png | Bin 0 -> 6956 bytes resources/img/pnwscala.png | Bin 0 -> 3038 bytes resources/img/pnwscala@2x.png | Bin 0 -> 7026 bytes resources/img/react.png | Bin 0 -> 5234 bytes resources/img/react@2x.png | Bin 0 -> 7849 bytes resources/img/reactivesummit2016.png | Bin 0 -> 7710 bytes resources/img/reactivesummit2016@x2.png | Bin 0 -> 15090 bytes resources/img/recent-date-icon.png | Bin 0 -> 1131 bytes resources/img/recent-date-icon@2x.png | Bin 0 -> 1490 bytes resources/img/rss-icon.png | Bin 0 -> 1293 bytes resources/img/rss-icon@2x.png | Bin 0 -> 1702 bytes resources/img/scala-downunder.png | Bin 0 -> 1928 bytes resources/img/scala-downunder@2x.png | Bin 0 -> 2678 bytes resources/img/scala-italy.jpeg | Bin 0 -> 2302 bytes resources/img/scala-italy@2x.jpeg | Bin 0 -> 3462 bytes resources/img/scala-logo-red-dark.png | Bin 0 -> 2028 bytes resources/img/scala-logo-red-dark@2x.png | Bin 0 -> 4121 bytes resources/img/scala-logo-red-footer.png | Bin 0 -> 1700 bytes resources/img/scala-logo-red-footer@2x.png | Bin 0 -> 3321 bytes resources/img/scala-logo-red-sm.png | Bin 0 -> 1105 bytes resources/img/scala-logo-red-sm@2x.png | Bin 0 -> 2161 bytes resources/img/scala-logo-red-spiral-dark.png | Bin 0 -> 5049 bytes resources/img/scala-logo-red-spiral.png | Bin 0 -> 5520 bytes resources/img/scala-logo-red.png | Bin 0 -> 2158 bytes resources/img/scala-logo-red@2x.png | Bin 0 -> 4266 bytes resources/img/scala-logo-white-footer.png | Bin 0 -> 1214 bytes resources/img/scala-logo-white-footer@2x.png | Bin 0 -> 2444 bytes resources/img/scala-logo-white-sm.png | Bin 0 -> 1361 bytes resources/img/scala-logo-white-sm@2x.png | Bin 0 -> 2777 bytes resources/img/scala-logo-white-spiral.png | Bin 0 -> 4347 bytes resources/img/scala-logo-white.png | Bin 0 -> 1886 bytes resources/img/scala-logo-white@2x.png | Bin 0 -> 3932 bytes resources/img/scala-logo.png | Bin 0 -> 3080 bytes resources/img/scala-matsuri.png | Bin 0 -> 2426 bytes resources/img/scala-matsuri@2x.png | Bin 0 -> 5190 bytes resources/img/scala-small-logo.png | Bin 0 -> 5154 bytes resources/img/scala-spiral-3d-2-noise.png | Bin 0 -> 335107 bytes .../img/scala-spiral-3d-2-toned-down.png | Bin 0 -> 24329 bytes resources/img/scala-spiral-3d-2.png | Bin 0 -> 22941 bytes resources/img/scala-spiral-3d.png | Bin 0 -> 23925 bytes resources/img/scala-spiral-navbar.png | Bin 0 -> 7627 bytes resources/img/scala-spiral-noise-sm.png | Bin 0 -> 34565 bytes resources/img/scala-spiral-noise-sm2.png | Bin 0 -> 327035 bytes resources/img/scala-spiral-noise-sm2.png.png | Bin 0 -> 269498 bytes resources/img/scala-spiral-noise-sm@2x.png | Bin 0 -> 186356 bytes resources/img/scala-spiral-white.png | Bin 0 -> 1442 bytes resources/img/scala-spiral-white.svg | 62 + resources/img/scala-spiral-white@2x.png | Bin 0 -> 2077 bytes resources/img/scala-spiral.png | Bin 0 -> 11449 bytes resources/img/scala-spiral.svg | 100 + resources/img/scala-spiral2.png | Bin 0 -> 10815 bytes resources/img/scala-swarm.png | Bin 0 -> 3037 bytes resources/img/scala-swarm@2x.png | Bin 0 -> 8862 bytes resources/img/scala-world.png | Bin 0 -> 1171 bytes resources/img/scala-world@2x.png | Bin 0 -> 8217 bytes resources/img/scala2013.png | Bin 0 -> 29582 bytes resources/img/scala2013@2x.png | Bin 0 -> 79369 bytes resources/img/scala2014.png | Bin 0 -> 52232 bytes resources/img/scala2014@2x.png | Bin 0 -> 182250 bytes resources/img/scala2016.png | Bin 0 -> 2322 bytes resources/img/scala2016@x2.png | Bin 0 -> 4327 bytes resources/img/scalabythebay.png | Bin 0 -> 2918 bytes resources/img/scalabythebay2016.png | Bin 0 -> 3621 bytes resources/img/scalabythebay2016@x2.png | Bin 0 -> 7216 bytes resources/img/scalabythebay@2x.png | Bin 0 -> 6406 bytes resources/img/scalabytheschuylkill.png | Bin 0 -> 2131 bytes resources/img/scalabytheschuylkill@x2.png | Bin 0 -> 3755 bytes resources/img/scaladays-15.png | Bin 0 -> 11927 bytes resources/img/scaladays.png | Bin 0 -> 10434 bytes resources/img/scaladays2.png | Bin 0 -> 17161 bytes resources/img/scaladays2014.png | Bin 0 -> 24702 bytes resources/img/scaladays2014@2x.png | Bin 0 -> 80522 bytes resources/img/scaladays2@2x.png | Bin 0 -> 36638 bytes resources/img/scaladays@2x.png | Bin 0 -> 21322 bytes resources/img/scalaexchange.png | Bin 0 -> 3440 bytes resources/img/scalaexchange@2x.png | Bin 0 -> 6790 bytes resources/img/scalaio.png | Bin 0 -> 1996 bytes resources/img/scalaio@2x.png | Bin 0 -> 3323 bytes resources/img/scalameta-sketch.jpg | Bin 0 -> 159379 bytes resources/img/scalapeno2014-logo.png | Bin 0 -> 46436 bytes resources/img/scalapolis.png | Bin 0 -> 3343 bytes resources/img/scalapolis@2x.png | Bin 0 -> 7853 bytes resources/img/scalar.png | Bin 0 -> 3913 bytes resources/img/scalar@2x.png | Bin 0 -> 9706 bytes resources/img/scalasphere.png | Bin 0 -> 4333 bytes resources/img/scalasphere@2x.png | Bin 0 -> 11856 bytes resources/img/scalasummit2014.png | Bin 0 -> 4985 bytes resources/img/scalasummit2014@2x.png | Bin 0 -> 16535 bytes resources/img/scalaua.png | Bin 0 -> 3759 bytes resources/img/scalaua@2x.png | Bin 0 -> 4897 bytes resources/img/scalaupnorth.png | Bin 0 -> 1741 bytes resources/img/scalaupnorth@2x.png | Bin 0 -> 3334 bytes resources/img/scalawave.png | Bin 0 -> 5303 bytes resources/img/scalawave@2x.png | Bin 0 -> 17551 bytes resources/img/sfscala.png | Bin 0 -> 2655 bytes resources/img/sfscala@2x.png | Bin 0 -> 5491 bytes resources/img/shadow.png | Bin 0 -> 2541 bytes resources/img/smooth-spiral.png | Bin 0 -> 12997 bytes resources/img/smooth-spiral@2x.png | Bin 0 -> 29870 bytes resources/img/splash.png | Bin 0 -> 4014 bytes resources/img/splash@2x.png | Bin 0 -> 9877 bytes resources/img/swiss-alps-sunset3.jpg | Bin 0 -> 663763 bytes resources/img/swiss-alps-sunset5-blurred.jpg | Bin 0 -> 157124 bytes .../img/swiss-alps-sunset5-dark-overlay.jpg | Bin 0 -> 209547 bytes .../img/swiss-alps-sunset5-short-blue.jpg | Bin 0 -> 133737 bytes resources/img/swiss-alps-sunset5-short.jpg | Bin 0 -> 280920 bytes resources/img/swiss-alps-sunset5-sm.jpg | Bin 0 -> 334220 bytes resources/img/swiss-alps-sunset5.jpg | Bin 0 -> 1680259 bytes resources/img/swiss-flag.png | Bin 0 -> 1215 bytes resources/img/swiss-flag@2x.png | Bin 0 -> 1355 bytes resources/img/test.png | Bin 0 -> 46603 bytes resources/img/transparent_noise.png | Bin 0 -> 82995 bytes resources/img/twitter-logo-blue.png | Bin 0 -> 1717 bytes resources/img/twitter-logo-blue@2x.png | Bin 0 -> 2486 bytes resources/img/twitter-logo-white-lg.png | Bin 0 -> 1860 bytes resources/img/twitter-logo-white-lg@2x.png | Bin 0 -> 2744 bytes resources/img/twitter-logo-white.png | Bin 0 -> 1233 bytes resources/img/twitter-logo-white@2x.png | Bin 0 -> 1541 bytes resources/img/twitter-logo.png | Bin 0 -> 2435 bytes resources/img/type-inf-code.png | Bin 0 -> 85446 bytes resources/img/typelevel.png | Bin 0 -> 2114 bytes resources/img/typelevel@2x.png | Bin 0 -> 4479 bytes resources/img/uberconf2014.png | Bin 0 -> 2661 bytes resources/img/uberconf2014@2x.png | Bin 0 -> 5796 bytes resources/img/view-leman-blurred.jpg | Bin 0 -> 240885 bytes resources/img/view-leman-blurred2.jpg | Bin 0 -> 261075 bytes resources/img/view-leman-gradient-map.jpg | Bin 0 -> 120359 bytes resources/img/view-leman-gradient-map2.jpg | Bin 0 -> 106131 bytes resources/img/view-leman-grayscale.jpg | Bin 0 -> 269532 bytes resources/img/view-leman-opt.jpg | Bin 0 -> 362940 bytes resources/img/view-leman-opt2.jpg | Bin 0 -> 273953 bytes resources/img/view-leman.jpg | Bin 0 -> 1157834 bytes resources/img/white-line.png | Bin 0 -> 924 bytes resources/img/winterretreat2016.png | Bin 0 -> 2068 bytes resources/img/winterretreat2016@2x.png | Bin 0 -> 5260 bytes resources/javascript/coursera/bargraphs.js | 363 - resources/javascript/coursera/degrees.js | 66 - .../coursera/difficulty-by-expertise.png | Bin 22046 -> 0 bytes .../coursera/difficulty-to-expertise.js | 93 - .../coursera/difficulty-to-field.js | 93 - resources/javascript/coursera/difficulty.png | Bin 53648 -> 0 bytes resources/javascript/coursera/editors.js | 93 - resources/javascript/coursera/editors.png | Bin 91191 -> 0 bytes .../javascript/coursera/fields-of-study.js | 85 - resources/javascript/coursera/g.pie.js | 1 - resources/javascript/coursera/g.raphael.js | 7 - .../javascript/coursera/grades-breakdown.js | 88 - .../coursera/jquery-jvectormap-1.1.1.min.js | 7 - resources/javascript/coursera/languages.js | 93 - resources/javascript/coursera/languges.png | Bin 32778 -> 0 bytes resources/javascript/coursera/raphael.js | 10 - resources/javascript/coursera/timespent.png | Bin 45809 -> 0 bytes .../coursera/what-interested-you.js | 20 - resources/javascript/coursera/where-apply.js | 20 - resources/javascript/coursera/whereapply.png | Bin 45899 -> 0 bytes .../javascript/coursera/worldmap-density.js | 18 - .../coursera/worldmap-population.js | 18 - resources/javascript/coursera/worldmap.js | 1 - .../javascript/coursera/worthit-followup.png | Bin 57983 -> 0 bytes resources/javascript/coursera/worthit.png | Bin 30320 -> 0 bytes resources/javascript/expandingImageMenu.js | 139 - resources/javascript/frontpage.js | 26 - resources/javascript/prettify/prettify.css | 1 - .../bootstrap-dropdown-app.js | 0 .../{javascript => js}/bootstrap-dropdown.js | 0 .../{javascript => js}/bootstrap-popover.js | 0 .../{javascript => js}/bootstrap-twipsy.js | 0 resources/js/functions.js | 508 + .../{javascript => js}/jquery.accordionza.js | 0 .../{javascript => js}/jquery.easing.1.3.js | 0 resources/{javascript => js}/jquery.easing.js | 0 resources/js/tweetMachine-update.js | 414 + resources/js/vendor/.tweetMachine.js.kate-swp | Bin 0 -> 212 bytes resources/js/vendor/codemirror/clike.js | 788 ++ resources/js/vendor/codemirror/codemirror.js | 9113 +++++++++++++++++ .../{javascript => js/vendor}/effects.core.js | 72 +- .../vendor}/effects.highlight.js | 0 resources/js/vendor/jekyll.search.min.js | 1 + resources/js/vendor/jquery.autocomplete.js | 992 ++ resources/{javascript => js/vendor}/jquery.js | 4 +- resources/js/vendor/jquery.sticky.js | 287 + resources/js/vendor/moment.min.js | 7 + .../{javascript => js/vendor}/moveScroller.js | 0 .../vendor}/prettify/lang-apollo.js | 0 .../vendor}/prettify/lang-clj.js | 0 .../vendor}/prettify/lang-css.js | 0 .../vendor}/prettify/lang-go.js | 0 .../vendor}/prettify/lang-hs.js | 0 .../vendor}/prettify/lang-lisp.js | 0 .../vendor}/prettify/lang-lua.js | 0 .../vendor}/prettify/lang-ml.js | 0 .../vendor}/prettify/lang-n.js | 0 .../vendor}/prettify/lang-proto.js | 0 .../vendor}/prettify/lang-scala.js | 0 .../vendor}/prettify/lang-sql.js | 0 .../vendor}/prettify/lang-tex.js | 0 .../vendor}/prettify/lang-vb.js | 0 .../vendor}/prettify/lang-vhdl.js | 0 .../vendor}/prettify/lang-wiki.js | 0 .../vendor}/prettify/lang-xq.js | 0 .../vendor}/prettify/lang-yaml.js | 0 .../vendor}/prettify/prettify.js | 0 resources/{javascript => js/vendor}/toc.js | 44 +- resources/js/vendor/unslider.js | 654 ++ resources/stylesheets/base.css | 220 - resources/stylesheets/custom.css | 4 - resources/stylesheets/docs.css | 317 - resources/stylesheets/frontpage.css | 61 - resources/stylesheets/pager.css | 34 - resources/stylesheets/prettify.css | 43 - resources/stylesheets/screen.css | 143 - resources/stylesheets/style.css | 218 - resources/stylesheets/syntax.css | 60 - resources/stylesheets/toc.css | 4 - scripts/ci.sh | 6 + search.html | 35 - sips/.jekyll-metadata | Bin 6730 -> 0 bytes sips/README.md | 15 - .../2009-06-02-early-member-definitions.md | 6 - .../_posts/2010-05-06-scala-specialization.md | 6 - .../2010-07-20-new-collection-classes.md | 6 - .../_posts/2011-10-13-string-interpolation.md | 17 - sips/index.md | 49 - sips/minutes-list.md | 16 - sips/pending/_posts/2014-06-27-42.type.md | 309 - ...2-07-make-types-behave-like-expressions.md | 203 - sips/pending/futures-promises.html | 10 - sips/pending/implicit-classes.html | 10 - sips/pending/inline-classes.html | 10 - .../modularizing-language-features.html | 10 - sips/pending/string-interpolation.html | 10 - sips/pending/type-dynamic.html | 10 - sips/pending/value-classes.html | 10 - sips/sip-list.md | 23 - sips/slip-submission.md | 26 - style/index.md | 167 - tutorials/index.md | 49 - tutorials/partest-guide.md | 66 - .../2017-02-13-higher-order-functions.md | 42 - .../_posts/2017-02-13-implicit-parameters.md | 58 - .../2017-02-13-mixin-class-composition.md | 55 - .../_posts/2017-02-13-polymorphic-methods.md | 34 - .../2017-02-13-sequence-comprehensions.md | 70 - .../tour/_posts/2017-02-13-tour-of-scala.md | 50 - 1250 files changed, 41541 insertions(+), 11469 deletions(-) delete mode 100644 CNAME create mode 100644 CODE_OF_CONDUCT.md rename {ba => _ba}/cheatsheets/index.md (97%) create mode 100644 _ba/tour/abstract-types.md create mode 100644 _ba/tour/annotations.md create mode 100644 _ba/tour/basics.md create mode 100644 _ba/tour/by-name-parameters.md create mode 100644 _ba/tour/case-classes.md create mode 100644 _ba/tour/classes.md rename ba/tutorials/tour/_posts/2017-02-13-compound-types.md => _ba/tour/compound-types.md (69%) create mode 100644 _ba/tour/currying.md create mode 100644 _ba/tour/default-parameter-values.md create mode 100644 _ba/tour/extractor-objects.md create mode 100644 _ba/tour/for-comprehensions.md create mode 100644 _ba/tour/generic-classes.md rename ba/tutorials/tour/_posts/2017-02-13-higher-order-functions.md => _ba/tour/higher-order-functions.md (52%) rename ba/tutorials/tour/_posts/2017-02-13-implicit-conversions.md => _ba/tour/implicit-conversions.md (59%) create mode 100644 _ba/tour/implicit-parameters.md create mode 100644 _ba/tour/inner-classes.md rename ba/tutorials/tour/_posts/2017-02-13-local-type-inference.md => _ba/tour/local-type-inference.md (63%) create mode 100644 _ba/tour/lower-type-bounds.md create mode 100644 _ba/tour/mixin-class-composition.md create mode 100644 _ba/tour/named-arguments.md create mode 100644 _ba/tour/nested-functions.md create mode 100644 _ba/tour/operators.md create mode 100644 _ba/tour/pattern-matching.md create mode 100644 _ba/tour/polymorphic-methods.md create mode 100644 _ba/tour/regular-expression-patterns.md create mode 100644 _ba/tour/self-types.md rename ba/tutorials/tour/_posts/2017-02-13-singleton-objects.md => _ba/tour/singleton-objects.md (82%) rename ba/tutorials/tour/_posts/2017-02-13-tour-of-scala.md => _ba/tour/tour-of-scala.md (90%) create mode 100644 _ba/tour/traits.md create mode 100644 _ba/tour/unified-types.md create mode 100644 _ba/tour/upper-type-bounds.md create mode 100644 _ba/tour/variances.md create mode 100644 _books/1-programming-in-scala-3rd.md create mode 100644 _books/2-scala-for-the-impatient.md create mode 100644 _books/3-programming-scala.md create mode 100644 _books/4-functional-programming-in-scala.md create mode 100644 _books/5-scala-in-depth.md create mode 100644 _books/6-scala-puzzlers.md create mode 100644 _data/doc-nav-header.yml create mode 100644 _data/docnames.yml create mode 100644 _data/footer.yml create mode 100644 _data/nav-header.yml create mode 100644 _data/overviews.yml create mode 100644 _data/sip-data.yml create mode 100644 _data/translations.yml rename {de => _de}/tutorials/scala-for-java-programmers.md (99%) rename {es => _es}/overviews/core/actors.md (99%) rename {es => _es}/overviews/core/string-interpolation.md (97%) rename {es => _es}/overviews/parallel-collections/architecture.md (92%) rename {es => _es}/overviews/parallel-collections/concrete-parallel-collections.md (99%) rename {es => _es}/overviews/parallel-collections/configuration.md (96%) rename {es => _es}/overviews/parallel-collections/conversions.md (95%) rename {es => _es}/overviews/parallel-collections/ctries.md (94%) rename {es => _es}/overviews/parallel-collections/custom-parallel-collections.md (99%) rename {es => _es}/overviews/parallel-collections/overview.md (99%) rename {es => _es}/overviews/parallel-collections/performance.md (95%) rename es/tutorials/tour/_posts/2017-02-13-abstract-types.md => _es/tour/abstract-types.md (96%) rename es/tutorials/tour/_posts/2017-02-13-annotations.md => _es/tour/annotations.md (98%) rename es/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md => _es/tour/anonymous-function-syntax.md (88%) rename es/tutorials/tour/_posts/2017-02-13-automatic-closures.md => _es/tour/automatic-closures.md (96%) rename es/tutorials/tour/_posts/2017-02-13-case-classes.md => _es/tour/case-classes.md (97%) rename es/tutorials/tour/_posts/2017-02-13-classes.md => _es/tour/classes.md (95%) rename es/tutorials/tour/_posts/2017-02-13-compound-types.md => _es/tour/compound-types.md (94%) rename es/tutorials/tour/_posts/2017-02-13-currying.md => _es/tour/currying.md (92%) rename es/tutorials/tour/_posts/2017-02-13-default-parameter-values.md => _es/tour/default-parameter-values.md (95%) rename es/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md => _es/tour/explicitly-typed-self-references.md (97%) rename es/tutorials/tour/_posts/2017-02-13-extractor-objects.md => _es/tour/extractor-objects.md (94%) rename es/tutorials/tour/_posts/2017-02-13-generic-classes.md => _es/tour/generic-classes.md (93%) rename es/tutorials/tour/_posts/2017-02-13-higher-order-functions.md => _es/tour/higher-order-functions.md (92%) create mode 100644 _es/tour/implicit-conversions.md rename es/tutorials/tour/_posts/2017-02-13-implicit-parameters.md => _es/tour/implicit-parameters.md (94%) rename es/tutorials/tour/_posts/2017-02-13-inner-classes.md => _es/tour/inner-classes.md (96%) rename es/tutorials/tour/_posts/2017-02-13-local-type-inference.md => _es/tour/local-type-inference.md (94%) rename es/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md => _es/tour/lower-type-bounds.md (94%) rename es/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md => _es/tour/mixin-class-composition.md (88%) rename es/tutorials/tour/_posts/2017-02-13-named-parameters.md => _es/tour/named-parameters.md (93%) rename es/tutorials/tour/_posts/2017-02-13-nested-functions.md => _es/tour/nested-functions.md (86%) rename es/tutorials/tour/_posts/2017-02-13-operators.md => _es/tour/operators.md (91%) rename es/tutorials/tour/_posts/2017-02-13-pattern-matching.md => _es/tour/pattern-matching.md (94%) rename es/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md => _es/tour/polymorphic-methods.md (91%) rename es/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md => _es/tour/regular-expression-patterns.md (95%) rename es/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md => _es/tour/sequence-comprehensions.md (95%) rename es/tutorials/tour/_posts/2017-02-13-singleton-objects.md => _es/tour/singleton-objects.md (89%) rename es/tutorials/tour/_posts/2017-02-13-tour-of-scala.md => _es/tour/tour-of-scala.md (98%) rename es/tutorials/tour/_posts/2017-02-13-traits.md => _es/tour/traits.md (92%) rename es/tutorials/tour/_posts/2017-02-13-unified-types.md => _es/tour/unified-types.md (96%) rename es/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md => _es/tour/upper-type-bounds.md (93%) rename es/tutorials/tour/_posts/2017-02-13-variances.md => _es/tour/variances.md (96%) rename {es => _es}/tutorials/scala-for-java-programmers.md (99%) rename {fr => _fr}/cheatsheets/index.md (97%) delete mode 100644 _includes/allsids.txt create mode 100644 _includes/blog-list.html create mode 100644 _includes/books.html delete mode 100644 _includes/cheatsheet-sidebar.txt delete mode 100644 _includes/collections.txt create mode 100644 _includes/column-list-of-items.html delete mode 100644 _includes/contributing-toc.txt create mode 100644 _includes/contributions-projects-list.html delete mode 100644 _includes/coursera-stats-js.txt create mode 100644 _includes/discourse.html delete mode 100644 _includes/disqus.txt create mode 100644 _includes/download-resource-list.html create mode 100644 _includes/downloads-list.html create mode 100644 _includes/events-training-list-bottom.html create mode 100644 _includes/events-training-list-top.html create mode 100644 _includes/footer.html delete mode 100644 _includes/footer.txt delete mode 100644 _includes/footerbar.txt delete mode 100644 _includes/frontpage-content.txt delete mode 100644 _includes/frontpage-footer.txt delete mode 100644 _includes/frontpage-header.txt delete mode 100644 _includes/gen-toc.txt rename _includes/{glossary-header.txt => glossary-header.html} (84%) delete mode 100644 _includes/glossary-sidebar.txt delete mode 100644 _includes/header-coursera.txt delete mode 100644 _includes/header.txt create mode 100644 _includes/headerbottom.html create mode 100644 _includes/headertop.html delete mode 100644 _includes/index-header.txt create mode 100644 _includes/inner-page-blog-detail-main-content.html create mode 100644 _includes/inner-page-main-content.html delete mode 100644 _includes/localized-overview-index.txt create mode 100644 _includes/masthead-community.html create mode 100644 _includes/masthead-documentation.html create mode 100644 _includes/navbar-inner.html create mode 100644 _includes/online-courses.html create mode 100644 _includes/paginator.html create mode 100644 _includes/scastie.html delete mode 100644 _includes/search-header.txt create mode 100644 _includes/sidebar-toc-glossary.html create mode 100644 _includes/sidebar-toc-multipage-overview.html create mode 100644 _includes/sidebar-toc-singlepage-overview.html create mode 100644 _includes/sidebar-toc-style.html create mode 100644 _includes/sidebar-toc-tour-overview.html create mode 100644 _includes/sidebar-toc.html delete mode 100644 _includes/sips-topbar.txt delete mode 100644 _includes/thanks-to.txt delete mode 100644 _includes/toc-large.txt delete mode 100644 _includes/toc.txt delete mode 100644 _includes/topbar.txt create mode 100644 _includes/tutorial-list.html create mode 100644 _includes/tutorial-toc.html delete mode 100644 _includes/tutorial-toc.txt create mode 100644 _includes/twitter-feed.html create mode 100644 _includes/upcoming-training.html delete mode 100644 _includes/worldmap.html rename {it => _it}/tutorials/scala-for-java-programmers.md (99%) rename {ja => _ja}/cheatsheets/index.md (98%) rename {ja => _ja}/overviews/collections/arrays.md (99%) rename {ja => _ja}/overviews/collections/concrete-immutable-collection-classes.md (99%) rename {ja => _ja}/overviews/collections/concrete-mutable-collection-classes.md (99%) rename {ja => _ja}/overviews/collections/conversions-between-java-and-scala-collections.md (95%) rename {ja => _ja}/overviews/collections/creating-collections-from-scratch.md (98%) rename {ja => _ja}/overviews/collections/equality.md (91%) rename {ja => _ja}/overviews/collections/introduction.md (97%) rename {ja => _ja}/overviews/collections/iterators.md (99%) rename {ja => _ja}/overviews/collections/maps.md (99%) rename {ja => _ja}/overviews/collections/migrating-from-scala-27.md (97%) rename {ja => _ja}/overviews/collections/overview.md (98%) rename {ja => _ja}/overviews/collections/performance-characteristics.md (98%) rename {ja => _ja}/overviews/collections/seqs.md (99%) rename {ja => _ja}/overviews/collections/sets.md (99%) rename {ja => _ja}/overviews/collections/strings.md (92%) rename {ja => _ja}/overviews/collections/trait-iterable.md (98%) rename {ja => _ja}/overviews/collections/trait-traversable.md (99%) rename {ja => _ja}/overviews/collections/views.md (98%) rename {ja => _ja}/overviews/core/futures.md (99%) rename {ja => _ja}/overviews/core/string-interpolation.md (97%) rename {ja => _ja}/overviews/core/value-classes.md (99%) rename {ja => _ja}/overviews/index.md (99%) rename {ja => _ja}/overviews/macros/annotations.md (99%) rename {ja => _ja}/overviews/macros/blackbox-whitebox.md (98%) rename {ja => _ja}/overviews/macros/bundles.md (95%) rename {ja => _ja}/overviews/macros/extractors.md (96%) rename {ja => _ja}/overviews/macros/implicits.md (98%) rename {ja => _ja}/overviews/macros/inference.md (86%) rename {ja => _ja}/overviews/macros/overview.md (98%) rename {ja => _ja}/overviews/macros/paradise.md (98%) rename {ja => _ja}/overviews/macros/quasiquotes.md (74%) rename {ja => _ja}/overviews/macros/roadmap.md (97%) rename {ja => _ja}/overviews/macros/typemacros.md (96%) rename {ja => _ja}/overviews/macros/typeproviders.md (98%) rename {ja => _ja}/overviews/macros/untypedmacros.md (99%) rename {ja => _ja}/overviews/macros/usecases.md (92%) rename {ja => _ja}/overviews/parallel-collections/architecture.md (98%) rename {ja => _ja}/overviews/parallel-collections/concrete-parallel-collections.md (98%) rename {ja => _ja}/overviews/parallel-collections/configuration.md (97%) rename {ja => _ja}/overviews/parallel-collections/conversions.md (96%) rename {ja => _ja}/overviews/parallel-collections/ctries.md (98%) rename {ja => _ja}/overviews/parallel-collections/custom-parallel-collections.md (99%) rename {ja => _ja}/overviews/parallel-collections/overview.md (98%) rename {ja => _ja}/overviews/parallel-collections/performance.md (99%) rename {ja => _ja}/overviews/reflection/annotations-names-scopes.md (92%) rename {ja => _ja}/overviews/reflection/environment-universes-mirrors.md (96%) rename {ja => _ja}/overviews/reflection/overview.md (98%) rename {ja => _ja}/overviews/reflection/symbols-trees-types.md (97%) rename {ja => _ja}/overviews/reflection/thread-safety.md (98%) rename {ja => _ja}/overviews/reflection/typetags-manifests.md (98%) rename ko/tutorials/tour/_posts/2017-02-13-abstract-types.md => _ko/tour/abstract-types.md (96%) rename ko/tutorials/tour/_posts/2017-02-13-annotations.md => _ko/tour/annotations.md (98%) rename ko/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md => _ko/tour/anonymous-function-syntax.md (88%) rename ko/tutorials/tour/_posts/2017-02-13-automatic-closures.md => _ko/tour/automatic-closures.md (96%) rename ko/tutorials/tour/_posts/2017-02-13-case-classes.md => _ko/tour/case-classes.md (98%) rename ko/tutorials/tour/_posts/2017-02-13-classes.md => _ko/tour/classes.md (95%) rename ko/tutorials/tour/_posts/2017-02-13-compound-types.md => _ko/tour/compound-types.md (93%) rename ko/tutorials/tour/_posts/2017-02-13-currying.md => _ko/tour/currying.md (91%) rename ko/tutorials/tour/_posts/2017-02-13-default-parameter-values.md => _ko/tour/default-parameter-values.md (96%) rename ko/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md => _ko/tour/explicitly-typed-self-references.md (97%) rename ko/tutorials/tour/_posts/2017-02-13-extractor-objects.md => _ko/tour/extractor-objects.md (94%) rename ko/tutorials/tour/_posts/2017-02-13-generic-classes.md => _ko/tour/generic-classes.md (94%) rename ko/tutorials/tour/_posts/2017-02-13-higher-order-functions.md => _ko/tour/higher-order-functions.md (91%) rename {ko/tutorials => _ko}/tour/implicit-conversions.md (95%) rename ko/tutorials/tour/_posts/2017-02-13-implicit-parameters.md => _ko/tour/implicit-parameters.md (96%) rename ko/tutorials/tour/_posts/2017-02-13-inner-classes.md => _ko/tour/inner-classes.md (97%) rename ko/tutorials/tour/_posts/2017-02-13-local-type-inference.md => _ko/tour/local-type-inference.md (95%) rename ko/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md => _ko/tour/lower-type-bounds.md (95%) rename ko/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md => _ko/tour/mixin-class-composition.md (88%) rename ko/tutorials/tour/_posts/2017-02-13-named-parameters.md => _ko/tour/named-parameters.md (92%) rename ko/tutorials/tour/_posts/2017-02-13-nested-functions.md => _ko/tour/nested-functions.md (88%) rename ko/tutorials/tour/_posts/2017-02-13-operators.md => _ko/tour/operators.md (91%) rename ko/tutorials/tour/_posts/2017-02-13-pattern-matching.md => _ko/tour/pattern-matching.md (94%) rename ko/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md => _ko/tour/polymorphic-methods.md (92%) rename ko/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md => _ko/tour/regular-expression-patterns.md (94%) rename ko/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md => _ko/tour/sequence-comprehensions.md (96%) rename {ko/tutorials => _ko}/tour/singleton-objects.md (90%) rename ko/tutorials/tour/_posts/2017-02-13-tour-of-scala.md => _ko/tour/tour-of-scala.md (98%) rename ko/tutorials/tour/_posts/2017-02-13-traits.md => _ko/tour/traits.md (94%) rename ko/tutorials/tour/_posts/2017-02-13-unified-types.md => _ko/tour/unified-types.md (96%) rename ko/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md => _ko/tour/upper-type-bounds.md (93%) rename ko/tutorials/tour/_posts/2017-02-13-variances.md => _ko/tour/variances.md (96%) rename {ko => _ko}/tutorials/scala-for-java-programmers.md (99%) create mode 100644 _layouts/blog-detail.html create mode 100644 _layouts/blog-list.html delete mode 100644 _layouts/default.html create mode 100644 _layouts/downloadpage.html create mode 100644 _layouts/events.html delete mode 100644 _layouts/guides-index.html delete mode 100644 _layouts/guides-thanks.html delete mode 100644 _layouts/index.html create mode 100644 _layouts/inner-page-community.html create mode 100644 _layouts/inner-page-documentation.html create mode 100644 _layouts/inner-page-no-masthead.html create mode 100644 _layouts/inner-page-parent-dropdown.html create mode 100644 _layouts/inner-page-parent.html create mode 100644 _layouts/inner-page.html create mode 100644 _layouts/multipage-overview.html delete mode 100644 _layouts/news-coursera.html delete mode 100644 _layouts/news.html delete mode 100644 _layouts/overview-large.html create mode 100644 _layouts/overviews.html delete mode 100644 _layouts/page.html delete mode 100644 _layouts/redirected.html delete mode 100644 _layouts/search.html create mode 100644 _layouts/singlepage-overview.html delete mode 100644 _layouts/sip-landing.html create mode 100644 _layouts/sips.html delete mode 100644 _layouts/slip.html create mode 100644 _layouts/style-guide.html create mode 100644 _layouts/tour.html create mode 100644 _layouts/training.html delete mode 100644 _layouts/tutorial.html rename {tutorials => _overviews}/FAQ/breakout.md (93%) rename {tutorials => _overviews}/FAQ/chaining-implicits.md (97%) rename {tutorials => _overviews}/FAQ/collections.md (99%) rename {tutorials => _overviews}/FAQ/context-bounds.md (96%) rename {tutorials => _overviews}/FAQ/finding-implicits.md (98%) rename {tutorials => _overviews}/FAQ/finding-symbols.md (97%) create mode 100644 _overviews/FAQ/index.md rename {tutorials => _overviews}/FAQ/initialization-order.md (98%) rename {tutorials => _overviews}/FAQ/stream-view-iterator.md (95%) rename {tutorials => _overviews}/FAQ/yield.md (94%) create mode 100644 _overviews/cheatsheets/index.md rename {overviews => _overviews}/collections/arrays.md (90%) rename {overviews => _overviews}/collections/concrete-immutable-collection-classes.md (99%) rename {overviews => _overviews}/collections/concrete-mutable-collection-classes.md (97%) rename {overviews => _overviews}/collections/conversions-between-java-and-scala-collections.md (93%) rename {overviews => _overviews}/collections/creating-collections-from-scratch.md (97%) rename {overviews => _overviews}/collections/equality.md (87%) rename {overviews => _overviews}/collections/introduction.md (97%) rename {overviews => _overviews}/collections/iterators.md (99%) rename {overviews => _overviews}/collections/maps.md (98%) rename {overviews => _overviews}/collections/migrating-from-scala-27.md (96%) rename {overviews => _overviews}/collections/overview.md (98%) rename {overviews => _overviews}/collections/performance-characteristics.md (97%) rename {overviews => _overviews}/collections/seqs.md (89%) rename {overviews => _overviews}/collections/sets.md (98%) rename {overviews => _overviews}/collections/strings.md (87%) rename {overviews => _overviews}/collections/trait-iterable.md (97%) rename {overviews => _overviews}/collections/trait-traversable.md (98%) rename {overviews => _overviews}/collections/views.md (98%) rename overviews/core/_posts/2012-11-08-actors-migration-guide.md => _overviews/core/actors-migration-guide.md (99%) rename overviews/core/_posts/2010-11-30-actors.md => _overviews/core/actors.md (99%) rename overviews/core/_posts/2010-12-15-architecture-of-scala-collections.md => _overviews/core/architecture-of-scala-collections.md (97%) rename overviews/core/_posts/2016-11-01-binary-compatibility-of-scala-releases.md => _overviews/core/binary-compatibility-of-scala-releases.md (78%) rename overviews/core/_posts/2012-09-20-futures.md => _overviews/core/futures.md (98%) rename overviews/core/_posts/2012-09-20-implicit-classes.md => _overviews/core/implicit-classes.md (91%) rename overviews/core/_posts/2012-09-21-string-interpolation.md => _overviews/core/string-interpolation.md (98%) rename overviews/core/_posts/2012-11-03-value-classes.md => _overviews/core/value-classes.md (99%) create mode 100644 _overviews/index.md rename {overviews => _overviews}/macros.html (90%) rename {overviews => _overviews}/macros/annotations.md (93%) rename {overviews => _overviews}/macros/blackbox-whitebox.md (89%) rename {overviews => _overviews}/macros/bundles.md (71%) rename {overviews => _overviews}/macros/changelog211.md (79%) rename {overviews => _overviews}/macros/extractors.md (91%) rename {overviews => _overviews}/macros/implicits.md (96%) rename {overviews => _overviews}/macros/inference.md (69%) rename {overviews => _overviews}/macros/overview.md (97%) rename {overviews => _overviews}/macros/paradise.md (89%) create mode 100644 _overviews/macros/quasiquotes.md create mode 100644 _overviews/macros/roadmap.md rename {overviews => _overviews}/macros/typemacros.md (85%) rename {overviews => _overviews}/macros/typeproviders.md (93%) rename {overviews => _overviews}/macros/untypedmacros.md (97%) rename {overviews => _overviews}/macros/usecases.md (88%) rename {overviews => _overviews}/parallel-collections/architecture.md (97%) rename {overviews => _overviews}/parallel-collections/concrete-parallel-collections.md (90%) rename {overviews => _overviews}/parallel-collections/configuration.md (95%) rename {overviews => _overviews}/parallel-collections/conversions.md (95%) rename {overviews => _overviews}/parallel-collections/ctries.md (98%) rename {overviews => _overviews}/parallel-collections/custom-parallel-collections.md (98%) rename {overviews => _overviews}/parallel-collections/overview.md (96%) create mode 100644 _overviews/parallel-collections/performance.md rename {overviews => _overviews}/quasiquotes/definition-details.md (95%) rename {overviews => _overviews}/quasiquotes/expression-details.md (92%) rename {overviews => _overviews}/quasiquotes/future.md (65%) rename {overviews => _overviews}/quasiquotes/hygiene.md (96%) rename {overviews => _overviews}/quasiquotes/intro.md (82%) rename {overviews => _overviews}/quasiquotes/lifting.md (93%) rename {overviews => _overviews}/quasiquotes/pattern-details.md (82%) rename {overviews => _overviews}/quasiquotes/setup.md (94%) rename {overviews => _overviews}/quasiquotes/syntax-summary.md (63%) rename {overviews => _overviews}/quasiquotes/terminology.md (52%) rename {overviews => _overviews}/quasiquotes/type-details.md (83%) rename {overviews => _overviews}/quasiquotes/unlifting.md (89%) rename {overviews => _overviews}/quasiquotes/usecases.md (93%) rename {overviews => _overviews}/reflection/annotations-names-scopes.md (91%) create mode 100644 _overviews/reflection/changelog211.md rename {overviews => _overviews}/reflection/environment-universes-mirrors.md (95%) rename {overviews => _overviews}/reflection/overview.md (97%) rename {overviews => _overviews}/reflection/symbols-trees-types.md (97%) rename {overviews => _overviews}/reflection/thread-safety.md (96%) rename {overviews => _overviews}/reflection/typetags-manifests.md (97%) rename {overviews => _overviews}/repl/embedding.md (94%) rename {overviews => _overviews}/repl/overview.md (95%) rename {overviews => _overviews}/scaladoc/basics.md (80%) rename {overviews => _overviews}/scaladoc/for-library-authors.md (97%) rename {overviews => _overviews}/scaladoc/interface.md (96%) rename {overviews => _overviews}/scaladoc/overview.md (63%) rename {overviews => _overviews}/scaladoc/usage.md (78%) create mode 100644 _overviews/tutorials/binary-compatibility-for-library-authors.md rename {tutorials => _overviews/tutorials}/scala-for-csharp-programmers.disabled.html (99%) rename {tutorials => _overviews/tutorials}/scala-for-java-programmers.md (98%) rename {tutorials => _overviews/tutorials}/scala-with-maven.md (99%) rename {pl => _pl}/cheatsheets/index.md (97%) rename pl/tutorials/tour/_posts/2017-02-13-abstract-types.md => _pl/tour/abstract-types.md (95%) rename pl/tutorials/tour/_posts/2017-02-13-annotations.md => _pl/tour/annotations.md (97%) rename pl/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md => _pl/tour/anonymous-function-syntax.md (85%) rename pl/tutorials/tour/_posts/2017-02-13-automatic-closures.md => _pl/tour/automatic-closures.md (94%) rename pl/tutorials/tour/_posts/2017-02-13-case-classes.md => _pl/tour/case-classes.md (97%) rename pl/tutorials/tour/_posts/2017-02-13-classes.md => _pl/tour/classes.md (94%) rename pl/tutorials/tour/_posts/2017-02-13-compound-types.md => _pl/tour/compound-types.md (91%) rename pl/tutorials/tour/_posts/2017-02-13-currying.md => _pl/tour/currying.md (88%) rename pl/tutorials/tour/_posts/2017-02-13-default-parameter-values.md => _pl/tour/default-parameter-values.md (95%) rename pl/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md => _pl/tour/explicitly-typed-self-references.md (97%) rename pl/tutorials/tour/_posts/2017-02-13-extractor-objects.md => _pl/tour/extractor-objects.md (93%) rename pl/tutorials/tour/_posts/2017-02-13-generic-classes.md => _pl/tour/generic-classes.md (91%) rename pl/tutorials/tour/_posts/2017-02-13-higher-order-functions.md => _pl/tour/higher-order-functions.md (89%) rename pl/tutorials/tour/_posts/2017-02-13-implicit-conversions.md => _pl/tour/implicit-conversions.md (93%) rename pl/tutorials/tour/_posts/2017-02-13-implicit-parameters.md => _pl/tour/implicit-parameters.md (95%) rename pl/tutorials/tour/_posts/2017-02-13-inner-classes.md => _pl/tour/inner-classes.md (95%) rename pl/tutorials/tour/_posts/2017-02-13-local-type-inference.md => _pl/tour/local-type-inference.md (94%) rename pl/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md => _pl/tour/lower-type-bounds.md (93%) rename pl/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md => _pl/tour/mixin-class-composition.md (86%) rename pl/tutorials/tour/_posts/2017-02-13-named-parameters.md => _pl/tour/named-parameters.md (88%) rename pl/tutorials/tour/_posts/2017-02-13-nested-functions.md => _pl/tour/nested-functions.md (85%) rename pl/tutorials/tour/_posts/2017-02-13-operators.md => _pl/tour/operators.md (85%) rename pl/tutorials/tour/_posts/2017-02-13-pattern-matching.md => _pl/tour/pattern-matching.md (92%) rename pl/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md => _pl/tour/polymorphic-methods.md (86%) rename pl/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md => _pl/tour/regular-expression-patterns.md (87%) rename pl/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md => _pl/tour/sequence-comprehensions.md (94%) rename pl/tutorials/tour/_posts/2017-02-13-singleton-objects.md => _pl/tour/singleton-objects.md (95%) rename pl/tutorials/tour/_posts/2017-02-13-tour-of-scala.md => _pl/tour/tour-of-scala.md (97%) rename pl/tutorials/tour/_posts/2017-02-13-traits.md => _pl/tour/traits.md (92%) rename pl/tutorials/tour/_posts/2017-02-13-unified-types.md => _pl/tour/unified-types.md (94%) rename pl/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md => _pl/tour/upper-type-bounds.md (91%) rename pl/tutorials/tour/_posts/2017-02-13-variances.md => _pl/tour/variances.md (95%) create mode 100644 _plugins/tut_replace.rb rename {pt-br => _pt-br}/cheatsheets/index.md (97%) rename pt-br/tutorials/tour/_posts/2017-02-13-abstract-types.md => _pt-br/tour/abstract-types.md (96%) rename pt-br/tutorials/tour/_posts/2017-02-13-annotations.md => _pt-br/tour/annotations.md (97%) rename pt-br/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md => _pt-br/tour/anonymous-function-syntax.md (85%) rename pt-br/tutorials/tour/_posts/2017-02-13-automatic-closures.md => _pt-br/tour/automatic-closures.md (95%) rename pt-br/tutorials/tour/_posts/2017-02-13-case-classes.md => _pt-br/tour/case-classes.md (97%) rename pt-br/tutorials/tour/_posts/2017-02-13-classes.md => _pt-br/tour/classes.md (94%) rename pt-br/tutorials/tour/_posts/2017-02-13-compound-types.md => _pt-br/tour/compound-types.md (91%) rename pt-br/tutorials/tour/_posts/2017-02-13-currying.md => _pt-br/tour/currying.md (90%) rename pt-br/tutorials/tour/_posts/2017-02-13-default-parameter-values.md => _pt-br/tour/default-parameter-values.md (95%) rename pt-br/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md => _pt-br/tour/explicitly-typed-self-references.md (97%) rename pt-br/tutorials/tour/_posts/2017-02-13-extractor-objects.md => _pt-br/tour/extractor-objects.md (93%) rename pt-br/tutorials/tour/_posts/2017-02-13-generic-classes.md => _pt-br/tour/generic-classes.md (92%) rename pt-br/tutorials/tour/_posts/2017-02-13-higher-order-functions.md => _pt-br/tour/higher-order-functions.md (88%) rename pt-br/tutorials/tour/_posts/2017-02-13-implicit-conversions.md => _pt-br/tour/implicit-conversions.md (93%) rename pt-br/tutorials/tour/_posts/2017-02-13-implicit-parameters.md => _pt-br/tour/implicit-parameters.md (95%) rename pt-br/tutorials/tour/_posts/2017-02-13-inner-classes.md => _pt-br/tour/inner-classes.md (95%) rename pt-br/tutorials/tour/_posts/2017-02-13-local-type-inference.md => _pt-br/tour/local-type-inference.md (94%) rename pt-br/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md => _pt-br/tour/lower-type-bounds.md (94%) rename pt-br/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md => _pt-br/tour/mixin-class-composition.md (86%) rename pt-br/tutorials/tour/_posts/2017-02-13-named-parameters.md => _pt-br/tour/named-parameters.md (90%) rename pt-br/tutorials/tour/_posts/2017-02-13-nested-functions.md => _pt-br/tour/nested-functions.md (85%) rename pt-br/tutorials/tour/_posts/2017-02-13-operators.md => _pt-br/tour/operators.md (86%) rename pt-br/tutorials/tour/_posts/2017-02-13-pattern-matching.md => _pt-br/tour/pattern-matching.md (93%) rename pt-br/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md => _pt-br/tour/polymorphic-methods.md (87%) rename pt-br/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md => _pt-br/tour/regular-expression-patterns.md (93%) rename pt-br/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md => _pt-br/tour/sequence-comprehensions.md (94%) rename pt-br/tutorials/tour/_posts/2017-02-13-singleton-objects.md => _pt-br/tour/singleton-objects.md (89%) rename pt-br/tutorials/tour/_posts/2017-02-13-tour-of-scala.md => _pt-br/tour/tour-of-scala.md (97%) rename pt-br/tutorials/tour/_posts/2017-02-13-traits.md => _pt-br/tour/traits.md (93%) rename pt-br/tutorials/tour/_posts/2017-02-13-unified-types.md => _pt-br/tour/unified-types.md (95%) rename pt-br/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md => _pt-br/tour/upper-type-bounds.md (91%) rename pt-br/tutorials/tour/_posts/2017-02-13-variances.md => _pt-br/tour/variances.md (95%) rename {ru => _ru}/overviews/parallel-collections/architecture.md (98%) rename {ru => _ru}/overviews/parallel-collections/concrete-parallel-collections.md (99%) rename {ru => _ru}/overviews/parallel-collections/configuration.md (98%) rename {ru => _ru}/overviews/parallel-collections/conversions.md (98%) rename {ru => _ru}/overviews/parallel-collections/ctries.md (98%) rename {ru => _ru}/overviews/parallel-collections/custom-parallel-collections.md (98%) rename {ru => _ru}/overviews/parallel-collections/overview.md (99%) rename {ru => _ru}/overviews/parallel-collections/performance.md (98%) create mode 100755 _sass/base/body.scss create mode 100755 _sass/base/form.scss create mode 100755 _sass/base/helper.scss create mode 100755 _sass/base/lists.scss create mode 100755 _sass/base/media.scss create mode 100755 _sass/base/typography.scss create mode 100755 _sass/components/buttons.scss create mode 100755 _sass/components/calendar.scss create mode 100755 _sass/components/call-to-action.scss create mode 100755 _sass/components/card.scss create mode 100755 _sass/components/code.scss create mode 100644 _sass/components/dropdown.scss create mode 100755 _sass/components/heading-line.scss create mode 100755 _sass/components/pagination.scss create mode 100755 _sass/components/search.scss create mode 100755 _sass/components/slider.scss create mode 100755 _sass/components/tab.scss create mode 100755 _sass/components/tag.scss create mode 100755 _sass/components/tooltip.scss create mode 100755 _sass/layout/blog.scss create mode 100755 _sass/layout/books.scss create mode 100644 _sass/layout/cheatsheet.scss create mode 100755 _sass/layout/courses.scss create mode 100644 _sass/layout/doc-navigation.scss create mode 100644 _sass/layout/documentation.scss create mode 100755 _sass/layout/download.scss create mode 100755 _sass/layout/footer.scss create mode 100644 _sass/layout/glossary.scss create mode 100755 _sass/layout/header.scss create mode 100755 _sass/layout/ides.scss create mode 100755 _sass/layout/inner-main.scss create mode 100755 _sass/layout/inner-text.scss create mode 100755 _sass/layout/maintenance.scss create mode 100755 _sass/layout/marker.scss create mode 100755 _sass/layout/navigation.scss create mode 100755 _sass/layout/new-blog.scss create mode 100755 _sass/layout/nutshell.scss create mode 100644 _sass/layout/overviews.scss create mode 100755 _sass/layout/run-scala.scss create mode 100755 _sass/layout/runs.scss create mode 100755 _sass/layout/scala-ecosystem.scss create mode 100755 _sass/layout/scala-main-resources.scss create mode 100755 _sass/layout/scaladex.scss create mode 100644 _sass/layout/sips.scss create mode 100755 _sass/layout/site-main.scss create mode 100644 _sass/layout/style-guide.scss create mode 100755 _sass/layout/table-of-content.scss create mode 100755 _sass/layout/talk-to-us.scss create mode 100755 _sass/layout/title-page.scss create mode 100644 _sass/layout/toc.scss create mode 100755 _sass/layout/tools.scss create mode 100755 _sass/layout/training-events.scss create mode 100755 _sass/layout/twitter-feed.scss create mode 100755 _sass/layout/type-md.scss create mode 100755 _sass/layout/upcoming-events.scss create mode 100755 _sass/utils/_mixins.scss create mode 100755 _sass/utils/_variables.scss create mode 100755 _sass/vendors/bourbon/_bourbon-deprecated-upcoming.scss create mode 100755 _sass/vendors/bourbon/_bourbon.scss create mode 100755 _sass/vendors/bourbon/addons/_border-color.scss create mode 100755 _sass/vendors/bourbon/addons/_border-radius.scss create mode 100755 _sass/vendors/bourbon/addons/_border-style.scss create mode 100755 _sass/vendors/bourbon/addons/_border-width.scss create mode 100755 _sass/vendors/bourbon/addons/_buttons.scss create mode 100755 _sass/vendors/bourbon/addons/_clearfix.scss create mode 100755 _sass/vendors/bourbon/addons/_ellipsis.scss create mode 100755 _sass/vendors/bourbon/addons/_font-stacks.scss create mode 100755 _sass/vendors/bourbon/addons/_hide-text.scss create mode 100755 _sass/vendors/bourbon/addons/_margin.scss create mode 100755 _sass/vendors/bourbon/addons/_padding.scss create mode 100755 _sass/vendors/bourbon/addons/_position.scss create mode 100755 _sass/vendors/bourbon/addons/_prefixer.scss create mode 100755 _sass/vendors/bourbon/addons/_retina-image.scss create mode 100755 _sass/vendors/bourbon/addons/_size.scss create mode 100755 _sass/vendors/bourbon/addons/_text-inputs.scss create mode 100755 _sass/vendors/bourbon/addons/_timing-functions.scss create mode 100755 _sass/vendors/bourbon/addons/_triangle.scss create mode 100755 _sass/vendors/bourbon/addons/_word-wrap.scss create mode 100755 _sass/vendors/bourbon/css3/_animation.scss create mode 100755 _sass/vendors/bourbon/css3/_appearance.scss create mode 100755 _sass/vendors/bourbon/css3/_backface-visibility.scss create mode 100755 _sass/vendors/bourbon/css3/_background-image.scss create mode 100755 _sass/vendors/bourbon/css3/_background.scss create mode 100755 _sass/vendors/bourbon/css3/_border-image.scss create mode 100755 _sass/vendors/bourbon/css3/_calc.scss create mode 100755 _sass/vendors/bourbon/css3/_columns.scss create mode 100755 _sass/vendors/bourbon/css3/_filter.scss create mode 100755 _sass/vendors/bourbon/css3/_flex-box.scss create mode 100755 _sass/vendors/bourbon/css3/_font-face.scss create mode 100755 _sass/vendors/bourbon/css3/_font-feature-settings.scss create mode 100755 _sass/vendors/bourbon/css3/_hidpi-media-query.scss create mode 100755 _sass/vendors/bourbon/css3/_hyphens.scss create mode 100755 _sass/vendors/bourbon/css3/_image-rendering.scss create mode 100755 _sass/vendors/bourbon/css3/_keyframes.scss create mode 100755 _sass/vendors/bourbon/css3/_linear-gradient.scss create mode 100755 _sass/vendors/bourbon/css3/_perspective.scss create mode 100755 _sass/vendors/bourbon/css3/_placeholder.scss create mode 100755 _sass/vendors/bourbon/css3/_radial-gradient.scss create mode 100755 _sass/vendors/bourbon/css3/_selection.scss create mode 100755 _sass/vendors/bourbon/css3/_text-decoration.scss create mode 100755 _sass/vendors/bourbon/css3/_transform.scss create mode 100755 _sass/vendors/bourbon/css3/_transition.scss create mode 100755 _sass/vendors/bourbon/css3/_user-select.scss create mode 100755 _sass/vendors/bourbon/functions/_assign-inputs.scss create mode 100755 _sass/vendors/bourbon/functions/_contains-falsy.scss create mode 100755 _sass/vendors/bourbon/functions/_contains.scss create mode 100755 _sass/vendors/bourbon/functions/_is-length.scss create mode 100755 _sass/vendors/bourbon/functions/_is-light.scss create mode 100755 _sass/vendors/bourbon/functions/_is-number.scss create mode 100755 _sass/vendors/bourbon/functions/_is-size.scss create mode 100755 _sass/vendors/bourbon/functions/_modular-scale.scss create mode 100755 _sass/vendors/bourbon/functions/_px-to-em.scss create mode 100755 _sass/vendors/bourbon/functions/_px-to-rem.scss create mode 100755 _sass/vendors/bourbon/functions/_shade.scss create mode 100755 _sass/vendors/bourbon/functions/_strip-units.scss create mode 100755 _sass/vendors/bourbon/functions/_tint.scss create mode 100755 _sass/vendors/bourbon/functions/_transition-property-name.scss create mode 100755 _sass/vendors/bourbon/functions/_unpack.scss create mode 100755 _sass/vendors/bourbon/helpers/_convert-units.scss create mode 100755 _sass/vendors/bourbon/helpers/_directional-values.scss create mode 100755 _sass/vendors/bourbon/helpers/_font-source-declaration.scss create mode 100755 _sass/vendors/bourbon/helpers/_gradient-positions-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_linear-angle-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_linear-gradient-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_linear-positions-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_linear-side-corner-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_radial-arg-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_radial-gradient-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_radial-positions-parser.scss create mode 100755 _sass/vendors/bourbon/helpers/_render-gradients.scss create mode 100755 _sass/vendors/bourbon/helpers/_shape-size-stripper.scss create mode 100755 _sass/vendors/bourbon/helpers/_str-to-num.scss create mode 100755 _sass/vendors/bourbon/settings/_asset-pipeline.scss create mode 100755 _sass/vendors/bourbon/settings/_prefixer.scss create mode 100755 _sass/vendors/bourbon/settings/_px-to-em.scss create mode 100755 _sass/vendors/neat/_neat-helpers.scss create mode 100755 _sass/vendors/neat/_neat.scss create mode 100755 _sass/vendors/neat/functions/_new-breakpoint.scss create mode 100755 _sass/vendors/neat/functions/_private.scss create mode 100755 _sass/vendors/neat/grid/_box-sizing.scss create mode 100755 _sass/vendors/neat/grid/_direction-context.scss create mode 100755 _sass/vendors/neat/grid/_display-context.scss create mode 100755 _sass/vendors/neat/grid/_fill-parent.scss create mode 100755 _sass/vendors/neat/grid/_media.scss create mode 100755 _sass/vendors/neat/grid/_omega.scss create mode 100755 _sass/vendors/neat/grid/_outer-container.scss create mode 100755 _sass/vendors/neat/grid/_pad.scss create mode 100755 _sass/vendors/neat/grid/_private.scss create mode 100755 _sass/vendors/neat/grid/_row.scss create mode 100755 _sass/vendors/neat/grid/_shift.scss create mode 100755 _sass/vendors/neat/grid/_span-columns.scss create mode 100755 _sass/vendors/neat/grid/_to-deprecate.scss create mode 100755 _sass/vendors/neat/grid/_visual-grid.scss create mode 100755 _sass/vendors/neat/mixins/_clearfix.scss create mode 100755 _sass/vendors/neat/settings/_disable-warnings.scss create mode 100755 _sass/vendors/neat/settings/_grid.scss create mode 100755 _sass/vendors/neat/settings/_visual-grid.scss create mode 100755 _sass/vendors/unslider/unslider.scss create mode 100755 _sass/vendors/unslider/unslider/dots.scss create mode 100755 _sass/vendors/unslider/unslider/reset.scss create mode 100755 _sass/vendors/unslider/variables.scss create mode 100644 _sips/README.md create mode 100644 _sips/all.md create mode 100644 _sips/index.md create mode 100644 _sips/minutes-list.md rename {sips/minutes/_posts => _sips/minutes}/2016-07-15-sip-minutes.md (98%) rename {sips/minutes/_posts => _sips/minutes}/2016-08-16-sip-10th-august-minutes.md (97%) rename {sips/minutes/_posts => _sips/minutes}/2016-09-20-sip-20th-september-minutes.md (97%) rename {sips/minutes/_posts => _sips/minutes}/2016-10-25-sip-minutes.md (97%) rename {sips/minutes/_posts => _sips/minutes}/2016-11-29-sip-minutes.md (96%) create mode 100644 _sips/minutes/2017-02-14-sip-minutes.md create mode 100644 _sips/minutes/2017-05-08-sip-minutes.md create mode 100644 _sips/minutes/2017-09-21-sip-minutes.md create mode 100644 _sips/minutes/2017-10-24-sip-minutes.md create mode 100644 _sips/minutes/2017-12-06-sip-minutes.md create mode 100644 _sips/minutes/_posts/2017-02-14-sip-minutes.md rename {sips => _sips}/sip-submission.md (95%) rename {sips => _sips}/sip-template.md (99%) rename {sips => _sips}/sip-tutorial.md (83%) rename {sips/completed/_posts => _sips/sips}/2009-05-28-scala-compiler-phase-plugin-in.md (61%) create mode 100644 _sips/sips/2009-06-02-early-member-definitions.md rename {sips/completed/_posts => _sips/sips}/2009-11-02-scala-swing-overview.md (55%) rename {sips/completed/_posts => _sips/sips}/2010-01-22-named-and-default-arguments.md (98%) rename {sips/completed/_posts => _sips/sips}/2010-01-22-scala-2-8-arrays.md (98%) rename {sips/completed/_posts => _sips/sips}/2010-01-27-internals-of-scala-annotations.md (50%) create mode 100644 _sips/sips/2010-05-06-scala-specialization.md rename {sips/completed/_posts => _sips/sips}/2010-06-01-picked-signatures.md (54%) create mode 100644 _sips/sips/2010-07-20-new-collection-classes.md rename {sips/completed/_posts => _sips/sips}/2011-10-12-implicit-classes.md (93%) create mode 100644 _sips/sips/2011-10-13-string-interpolation.md rename {sips/rejected/_posts => _sips/sips}/2011-10-13-uncluttering-control.md (98%) rename {sips/completed/_posts => _sips/sips}/2012-01-21-futures-promises.md (98%) rename {sips/completed/_posts => _sips/sips}/2012-01-30-value-classes.md (92%) rename {sips/rejected/_posts => _sips/sips}/2012-03-09-self-cleaning-macros.md (84%) rename {sips/completed/_posts => _sips/sips}/2012-03-13-type-dynamic.md (62%) rename {sips/completed/_posts => _sips/sips}/2012-03-17-modularizing-language-features.md (76%) rename {sips/rejected/_posts => _sips/sips}/2012-03-30-source-locations.md (98%) rename {sips/pending/_posts => _sips/sips}/2013-05-31-improved-lazy-val-initialization.md (99%) rename {sips/pending/_posts => _sips/sips}/2013-06-10-spores.md (99%) rename {sips/pending/_posts => _sips/sips}/2013-06-30-async.md (98%) create mode 100644 _sips/sips/2014-06-27-42.type.md rename {sips/pending/_posts => _sips/sips}/2015-6-18-repeated-byname.md (96%) rename {sips/pending/_posts => _sips/sips}/2015-6-18-trait-parameters.md (97%) rename {sips/pending/_posts => _sips/sips}/2016-01-11-static-members.md (95%) rename {sips/completed/_posts => _sips/sips}/2016-06-25-trailing-commas.md (93%) rename {sips/rejected/_posts => _sips/sips}/2016-07-25-unsigned-integers.md (99%) rename {sips/pending/_posts => _sips/sips}/2016-09-09-inline-meta.md (99%) rename {sips/pending/_posts => _sips/sips}/2017-01-11-refer-other-arguments-in-args.md (94%) rename {sips/pending/_posts => _sips/sips}/2017-01-13-binary-compatibility.md (90%) create mode 100644 _sips/sips/2017-02-07-priority-based-infix-type-precedence.md rename {sips/pending/_posts => _sips/sips}/2017-02-22-comonadic-comprehensions.md (91%) create mode 100644 _sips/sips/2017-07-12-right-associative-by-name-operators.md create mode 100644 _sips/sips/2017-09-20-opaque-types.md create mode 100644 _sips/sips/2017-10-25-adding-prefix-types.md rename {style => _style}/control-structures.md (98%) rename {style => _style}/declarations.md (98%) rename {style => _style}/files.md (97%) rename {style => _style}/indentation.md (97%) create mode 100644 _style/index.md rename {style => _style}/method-invocation.md (98%) rename {style => _style}/naming-conventions.md (99%) rename {style => _style}/nested-blocks.md (94%) rename {style => _style}/overview.md (72%) rename {style => _style}/scaladoc.md (80%) rename {style => _style}/types.md (98%) rename tutorials/tour/_posts/2017-02-13-abstract-types.md => _tour/abstract-types.md (95%) rename tutorials/tour/_posts/2017-02-13-annotations.md => _tour/annotations.md (96%) rename tutorials/tour/_posts/2017-02-13-basics.md => _tour/basics.md (97%) rename tutorials/tour/_posts/2017-02-13-by-name-parameters.md => _tour/by-name-parameters.md (79%) rename tutorials/tour/_posts/2017-02-13-case-classes.md => _tour/case-classes.md (82%) rename tutorials/tour/_posts/2017-02-13-classes.md => _tour/classes.md (96%) rename tutorials/tour/_posts/2017-02-13-compound-types.md => _tour/compound-types.md (88%) rename tutorials/tour/_posts/2017-02-13-currying.md => _tour/currying.md (91%) rename tutorials/tour/_posts/2017-02-13-default-parameter-values.md => _tour/default-parameter-values.md (91%) rename {tutorials/tour => _tour}/dot-hot-reload.sh (100%) rename tutorials/tour/_posts/2017-02-13-extractor-objects.md => _tour/extractor-objects.md (82%) create mode 100644 _tour/for-comprehensions.md rename tutorials/tour/_posts/2017-02-13-generic-classes.md => _tour/generic-classes.md (94%) create mode 100644 _tour/higher-order-functions.md rename tutorials/tour/_posts/2017-02-13-implicit-conversions.md => _tour/implicit-conversions.md (95%) create mode 100644 _tour/implicit-parameters.md rename tutorials/tour/_posts/2017-02-13-inner-classes.md => _tour/inner-classes.md (96%) rename tutorials/tour/_posts/2017-02-13-local-type-inference.md => _tour/local-type-inference.md (95%) rename tutorials/tour/_posts/2017-02-13-lower-type-bounds.md => _tour/lower-type-bounds.md (82%) create mode 100644 _tour/mixin-class-composition.md rename tutorials/tour/_posts/2017-02-13-named-arguments.md => _tour/named-arguments.md (61%) rename tutorials/tour/_posts/2017-02-13-nested-functions.md => _tour/nested-functions.md (63%) rename tutorials/tour/_posts/2017-02-13-operators.md => _tour/operators.md (93%) create mode 100644 _tour/packages-and-imports.md rename tutorials/tour/_posts/2017-02-13-pattern-matching.md => _tour/pattern-matching.md (96%) create mode 100644 _tour/polymorphic-methods.md rename tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md => _tour/regular-expression-patterns.md (91%) rename tutorials/tour/_posts/2017-02-13-self-types.md => _tour/self-types.md (84%) rename tutorials/tour/_posts/2017-02-13-singleton-objects.md => _tour/singleton-objects.md (89%) create mode 100644 _tour/tour-of-scala.md rename tutorials/tour/_posts/2017-02-13-traits.md => _tour/traits.md (88%) rename tutorials/tour/_posts/2017-02-13-unified-types.md => _tour/unified-types.md (79%) rename tutorials/tour/_posts/2017-02-13-upper-type-bounds.md => _tour/upper-type-bounds.md (91%) rename tutorials/tour/_posts/2017-02-13-variances.md => _tour/variances.md (92%) create mode 100644 _zh-cn/cheatsheets/index.md create mode 100644 _zh-cn/thanks.md rename {zh-tw => _zh-tw}/tutorials/scala-for-java-programmers.md (99%) create mode 100644 api/all.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-abstract-types.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-annotations.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-automatic-closures.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-case-classes.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-classes.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-currying.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-default-parameter-values.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-extractor-objects.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-generic-classes.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-implicit-parameters.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-inner-classes.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-named-parameters.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-nested-functions.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-operators.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-pattern-matching.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-traits.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-unified-types.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md delete mode 100644 ba/tutorials/tour/_posts/2017-02-13-variances.md create mode 100644 books.md delete mode 100644 cheatsheets/index.md delete mode 100644 de/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md delete mode 100644 es/overviews/core/parallel-collections.md delete mode 100644 es/overviews/index.md delete mode 100644 es/tutorials/tour/_posts/2017-02-13-implicit-conversions.md create mode 100644 getting-started-intellij-track/building-a-scala-project-with-intellij-and-sbt.md create mode 100644 getting-started-intellij-track/getting-started-with-scala-in-intellij.md create mode 100644 getting-started-intellij-track/testing-scala-in-intellij-with-scalatest.md create mode 100644 getting-started-sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md create mode 100644 getting-started-sbt-track/testing-scala-with-sbt-on-the-command-line.md create mode 100644 getting-started.md create mode 100644 guides.md delete mode 100644 ja/overviews/core/collections.md delete mode 100644 ja/overviews/core/macros.md delete mode 100644 ja/overviews/core/parallel-collections.md delete mode 100644 ja/overviews/core/reflection.md create mode 100644 learn.md delete mode 100644 overviews/core/_posts/2010-09-07-collections.md delete mode 100644 overviews/core/_posts/2012-03-27-parallel-collections.md delete mode 100644 overviews/core/_posts/2012-12-20-macros.md delete mode 100644 overviews/core/_posts/2013-01-02-reflection.md delete mode 100644 overviews/index.md delete mode 100644 overviews/macros/quasiquotes.md delete mode 100644 overviews/macros/roadmap.md delete mode 100644 overviews/parallel-collections/performance.md delete mode 100644 overviews/reflection/changelog211.md create mode 100644 reference.md rename resources/{stylesheets => css}/bootstrap.css (100%) create mode 100644 resources/css/highlightjs.css create mode 100644 resources/css/monospace.css create mode 100644 resources/css/prettify.css rename resources/{stylesheets => css}/search.css (100%) create mode 100755 resources/css/style.scss create mode 100755 resources/css/unslider-dots.css create mode 100755 resources/css/unslider.css create mode 100644 resources/css/vendor/codemirror.css create mode 100644 resources/css/vendor/monokai.css create mode 100644 resources/glyphs/Consolas-Bold.eot create mode 100644 resources/glyphs/Consolas-Bold.ttf create mode 100644 resources/glyphs/Consolas-Bold.woff create mode 100644 resources/glyphs/Consolas-BoldItalic.eot create mode 100644 resources/glyphs/Consolas-BoldItalic.ttf create mode 100644 resources/glyphs/Consolas-BoldItalic.woff create mode 100644 resources/glyphs/Consolas-Italic.eot create mode 100644 resources/glyphs/Consolas-Italic.ttf create mode 100644 resources/glyphs/Consolas-Italic.woff create mode 100644 resources/glyphs/Consolas.eot create mode 100644 resources/glyphs/Consolas.ttf create mode 100644 resources/glyphs/Consolas.woff create mode 100644 resources/images/library-author-guide/after_update.png create mode 100644 resources/images/library-author-guide/backwards_forwards_compatibility.plantuml create mode 100644 resources/images/library-author-guide/before_update.png create mode 100644 resources/images/library-author-guide/dependency_hell.plantuml create mode 100644 resources/images/library-author-guide/dependency_hell.png create mode 100644 resources/images/library-author-guide/fowards_backwards_compatibility.png rename {tutorials => resources/images}/tour/Makefile (100%) rename {tutorials => resources/images}/tour/type-casting-diagram.dot (100%) rename {tutorials => resources/images}/tour/type-casting-diagram.svg (100%) rename {tutorials => resources/images}/tour/unified-types-diagram.dot (100%) rename {tutorials => resources/images}/tour/unified-types-diagram.svg (100%) rename {tutorials => resources/img}/01-post.png (100%) rename {tutorials => resources/img}/02-post.png (100%) rename {tutorials => resources/img}/03-fork.png (100%) rename {tutorials => resources/img}/04-submit.png (100%) rename {tutorials => resources/img}/05-review.png (100%) create mode 100644 resources/img/bee-scala.png create mode 100644 resources/img/bee-scala@2x.png create mode 100644 resources/img/black-topo-pattern.jpg create mode 100644 resources/img/blog/scaladex/head-project-background.png create mode 100644 resources/img/blog/scastie/scastie.png create mode 100644 resources/img/blue-overlay.png create mode 100644 resources/img/books.png create mode 100644 resources/img/books/BeginningScala.gif create mode 100644 resources/img/books/FPiS_93x116.png create mode 100644 resources/img/books/Pol_89x116.png create mode 100644 resources/img/books/ProgScalaJP.gif create mode 100644 resources/img/books/ProgrammingInScala.gif create mode 100644 resources/img/books/ProgrammingScala-final-border.gif create mode 100644 resources/img/books/ProgrammingScala.gif create mode 100644 resources/img/books/ProgrammingScala.jpg create mode 100644 resources/img/books/Scala_in_Action.jpg create mode 100644 resources/img/books/Umsteiger.png create mode 100644 resources/img/books/buildingRecommendationEngine.jpg create mode 100644 resources/img/books/heiko_117x82.jpg create mode 100644 resources/img/books/icon_Scala_in_Action_93x116.png create mode 100644 resources/img/books/icon_Scala_in_Depth_93x116.png create mode 100644 resources/img/books/icon_funkt_Grundkurs_91x115.png create mode 100644 resources/img/books/icon_hanser_90x113.png create mode 100644 resources/img/books/learningConcurrentProgrammingCover120x149.jpg create mode 100644 resources/img/books/puzzlersCover117x89.gif create mode 100644 resources/img/books/scala-puzzlers-book.jpg create mode 100644 resources/img/books/scalaForDataScience.jpg create mode 100644 resources/img/books/scala_for_the_impatient.png create mode 100644 resources/img/books/steps-v2.gif create mode 100644 resources/img/books/swedish_86x115.png create mode 100644 resources/img/books@2x.png create mode 100644 resources/img/carousel-bg.png create mode 100644 resources/img/code-mesh.png create mode 100644 resources/img/code-mesh@2x.png create mode 100644 resources/img/cufp.png create mode 100644 resources/img/cufp@2x.png create mode 100644 resources/img/curryon.png create mode 100644 resources/img/curryon@2x.png create mode 100644 resources/img/data-day.png create mode 100644 resources/img/data-day@2x.png create mode 100644 resources/img/date-icon.png create mode 100644 resources/img/date-icon@2x.png create mode 100644 resources/img/devoxx.png create mode 100644 resources/img/devoxx@2x.png create mode 100644 resources/img/diamond.png create mode 100644 resources/img/documentation-logo.png create mode 100644 resources/img/documentation-logo@2x.png create mode 100644 resources/img/dot-grid.png create mode 100644 resources/img/dot-grid2.png create mode 100644 resources/img/dot-grid3.png create mode 100644 resources/img/dot-grid4.png create mode 100644 resources/img/download.png create mode 100644 resources/img/download/arrow-asset.png create mode 100644 resources/img/download/arrow-left.png create mode 100644 resources/img/download/arrow-right.png create mode 100644 resources/img/epfl-bc.jpg create mode 100644 resources/img/epfl-logo.png create mode 100644 resources/img/epfl-logo@2x.png create mode 100644 resources/img/fby.png create mode 100644 resources/img/flatmap-oslo-17.png create mode 100644 resources/img/flatmap-oslo-17@2x.png create mode 100644 resources/img/flatmap-oslo-new.png create mode 100644 resources/img/flatmap-oslo-new@2x.png create mode 100644 resources/img/flatmap-oslo.png create mode 100644 resources/img/flatmap-oslo@2x.png create mode 100644 resources/img/fp-exchange.png create mode 100644 resources/img/fp-exchange@2x.png create mode 100644 resources/img/frontpage/47deg-logo.png create mode 100644 resources/img/frontpage/arrow.png create mode 100644 resources/img/frontpage/atom.png create mode 100644 resources/img/frontpage/avatar-twitter-feed.jpg create mode 100644 resources/img/frontpage/background-header-home.jpg create mode 100644 resources/img/frontpage/background-scala-ecosystem.png create mode 100644 resources/img/frontpage/background.png create mode 100644 resources/img/frontpage/beta.png create mode 100644 resources/img/frontpage/button-github.png create mode 100644 resources/img/frontpage/company-logo.png create mode 100644 resources/img/frontpage/coursera-icon.png create mode 100644 resources/img/frontpage/discourse-logo.png create mode 100644 resources/img/frontpage/eclipse.png create mode 100644 resources/img/frontpage/edx-icon.png create mode 100644 resources/img/frontpage/ensime.png create mode 100644 resources/img/frontpage/epfl-bc.jpg create mode 100644 resources/img/frontpage/epfl-logo.png create mode 100644 resources/img/frontpage/gitter-logo.png create mode 100644 resources/img/frontpage/goldman-logo.png create mode 100644 resources/img/frontpage/ibm-logo.png create mode 100644 resources/img/frontpage/icon-ensime.png create mode 100644 resources/img/frontpage/intelliJ.png create mode 100644 resources/img/frontpage/java-logo.png create mode 100644 resources/img/frontpage/js-logo.png create mode 100644 resources/img/frontpage/lightbend-logo.png create mode 100644 resources/img/frontpage/nitro-logo.png create mode 100644 resources/img/frontpage/sap-logo.png create mode 100644 resources/img/frontpage/scala-logo-white.png create mode 100644 resources/img/frontpage/scala-logo-white@2x.png create mode 100644 resources/img/frontpage/scala-spiral.png create mode 100644 resources/img/frontpage/scalacenter-logo.png create mode 100644 resources/img/frontpage/scaladex-logo.png create mode 100644 resources/img/frontpage/sublime.png create mode 100644 resources/img/frontpage/tapad-logo.png create mode 100644 resources/img/frontpage/verizon-logo.png create mode 100644 resources/img/funcconf.png create mode 100644 resources/img/funcconf@2x.png create mode 100644 resources/img/gears.png create mode 100644 resources/img/gears@2x.png create mode 100644 resources/img/github-logo.png create mode 100644 resources/img/github-logo@2x.png create mode 100644 resources/img/glyphicons-halflings-white.png create mode 100644 resources/img/glyphicons-halflings.png create mode 100644 resources/img/gray-line.png create mode 100644 resources/img/gsoc-2014-scala-logo.png create mode 100644 resources/img/hof-code.png create mode 100644 resources/img/hof-code1.png create mode 100644 resources/img/hof-code2.png create mode 100644 resources/img/icfp.png create mode 100644 resources/img/icfp@2x.png create mode 100644 resources/img/icon-announcement.png create mode 100644 resources/img/icon-dsls.png create mode 100644 resources/img/icon-functions.png create mode 100644 resources/img/icon-immutability.png create mode 100644 resources/img/icon-implicits.png create mode 100644 resources/img/icon-java-interop.png create mode 100644 resources/img/icon-parallelism-distribution.png create mode 100644 resources/img/icon-pattern-matching.png create mode 100644 resources/img/icon-traits.png create mode 100644 resources/img/icon-type-inference.png create mode 100644 resources/img/img-overlay.png create mode 100644 resources/img/katsconf.png create mode 100644 resources/img/katsconf@2x.png create mode 100644 resources/img/lac-leman.jpg create mode 100644 resources/img/lambda-days.png create mode 100644 resources/img/lambda-days2.png create mode 100644 resources/img/lambda-days2@2x.png create mode 100644 resources/img/lambda-days@2x.png create mode 100644 resources/img/lambda-jam.png create mode 100644 resources/img/lambda-jam@2x.png create mode 100644 resources/img/lambda-world.png create mode 100644 resources/img/lambda-world@2x.png create mode 100644 resources/img/lambdaconf.png create mode 100644 resources/img/lambdaconf@2x.png create mode 100644 resources/img/list.png create mode 100644 resources/img/list@2x.png create mode 100644 resources/img/logos/Apple_logo.png create mode 100644 resources/img/logos/Apple_logo_black.png create mode 100644 resources/img/logos/Apple_logo_black.svg create mode 100644 resources/img/logos/Bsd_daemon.png create mode 100644 resources/img/logos/Bsd_daemon.svg create mode 100644 resources/img/logos/Bsd_daemon_BW.png create mode 100644 resources/img/logos/Cygwin_logo.png create mode 100644 resources/img/logos/Cygwin_logo.svg create mode 100644 resources/img/logos/Tux.png create mode 100644 resources/img/logos/Tux.svg create mode 100644 resources/img/logos/Tux_BW.png create mode 100644 resources/img/logos/Windows_logo.png create mode 100644 resources/img/logos/Windows_logo.svg create mode 100644 resources/img/logos/Windows_logo_BW.png create mode 100644 resources/img/nescala-logo.png create mode 100644 resources/img/nescala.png create mode 100644 resources/img/nescala@2x.png create mode 100644 resources/img/patmat-code.png create mode 100644 resources/img/pdf-red.png create mode 100644 resources/img/pdf-red@2x.png create mode 100644 resources/img/pdf.png create mode 100644 resources/img/pdf@2x.png create mode 100644 resources/img/phillyete2014.png create mode 100644 resources/img/phillyete2014@2x.png create mode 100644 resources/img/pnwscala.png create mode 100644 resources/img/pnwscala@2x.png create mode 100644 resources/img/react.png create mode 100644 resources/img/react@2x.png create mode 100644 resources/img/reactivesummit2016.png create mode 100644 resources/img/reactivesummit2016@x2.png create mode 100644 resources/img/recent-date-icon.png create mode 100644 resources/img/recent-date-icon@2x.png create mode 100644 resources/img/rss-icon.png create mode 100644 resources/img/rss-icon@2x.png create mode 100644 resources/img/scala-downunder.png create mode 100644 resources/img/scala-downunder@2x.png create mode 100644 resources/img/scala-italy.jpeg create mode 100644 resources/img/scala-italy@2x.jpeg create mode 100644 resources/img/scala-logo-red-dark.png create mode 100644 resources/img/scala-logo-red-dark@2x.png create mode 100644 resources/img/scala-logo-red-footer.png create mode 100644 resources/img/scala-logo-red-footer@2x.png create mode 100644 resources/img/scala-logo-red-sm.png create mode 100644 resources/img/scala-logo-red-sm@2x.png create mode 100644 resources/img/scala-logo-red-spiral-dark.png create mode 100644 resources/img/scala-logo-red-spiral.png create mode 100644 resources/img/scala-logo-red.png create mode 100644 resources/img/scala-logo-red@2x.png create mode 100644 resources/img/scala-logo-white-footer.png create mode 100644 resources/img/scala-logo-white-footer@2x.png create mode 100644 resources/img/scala-logo-white-sm.png create mode 100644 resources/img/scala-logo-white-sm@2x.png create mode 100644 resources/img/scala-logo-white-spiral.png create mode 100644 resources/img/scala-logo-white.png create mode 100644 resources/img/scala-logo-white@2x.png create mode 100644 resources/img/scala-logo.png create mode 100644 resources/img/scala-matsuri.png create mode 100644 resources/img/scala-matsuri@2x.png create mode 100644 resources/img/scala-small-logo.png create mode 100644 resources/img/scala-spiral-3d-2-noise.png create mode 100644 resources/img/scala-spiral-3d-2-toned-down.png create mode 100644 resources/img/scala-spiral-3d-2.png create mode 100644 resources/img/scala-spiral-3d.png create mode 100644 resources/img/scala-spiral-navbar.png create mode 100644 resources/img/scala-spiral-noise-sm.png create mode 100644 resources/img/scala-spiral-noise-sm2.png create mode 100644 resources/img/scala-spiral-noise-sm2.png.png create mode 100644 resources/img/scala-spiral-noise-sm@2x.png create mode 100644 resources/img/scala-spiral-white.png create mode 100644 resources/img/scala-spiral-white.svg create mode 100644 resources/img/scala-spiral-white@2x.png create mode 100644 resources/img/scala-spiral.png create mode 100644 resources/img/scala-spiral.svg create mode 100644 resources/img/scala-spiral2.png create mode 100644 resources/img/scala-swarm.png create mode 100644 resources/img/scala-swarm@2x.png create mode 100644 resources/img/scala-world.png create mode 100644 resources/img/scala-world@2x.png create mode 100644 resources/img/scala2013.png create mode 100644 resources/img/scala2013@2x.png create mode 100644 resources/img/scala2014.png create mode 100644 resources/img/scala2014@2x.png create mode 100644 resources/img/scala2016.png create mode 100644 resources/img/scala2016@x2.png create mode 100644 resources/img/scalabythebay.png create mode 100644 resources/img/scalabythebay2016.png create mode 100644 resources/img/scalabythebay2016@x2.png create mode 100644 resources/img/scalabythebay@2x.png create mode 100644 resources/img/scalabytheschuylkill.png create mode 100644 resources/img/scalabytheschuylkill@x2.png create mode 100644 resources/img/scaladays-15.png create mode 100644 resources/img/scaladays.png create mode 100644 resources/img/scaladays2.png create mode 100644 resources/img/scaladays2014.png create mode 100644 resources/img/scaladays2014@2x.png create mode 100644 resources/img/scaladays2@2x.png create mode 100644 resources/img/scaladays@2x.png create mode 100644 resources/img/scalaexchange.png create mode 100644 resources/img/scalaexchange@2x.png create mode 100644 resources/img/scalaio.png create mode 100644 resources/img/scalaio@2x.png create mode 100644 resources/img/scalameta-sketch.jpg create mode 100644 resources/img/scalapeno2014-logo.png create mode 100644 resources/img/scalapolis.png create mode 100644 resources/img/scalapolis@2x.png create mode 100644 resources/img/scalar.png create mode 100644 resources/img/scalar@2x.png create mode 100644 resources/img/scalasphere.png create mode 100644 resources/img/scalasphere@2x.png create mode 100644 resources/img/scalasummit2014.png create mode 100644 resources/img/scalasummit2014@2x.png create mode 100644 resources/img/scalaua.png create mode 100644 resources/img/scalaua@2x.png create mode 100644 resources/img/scalaupnorth.png create mode 100644 resources/img/scalaupnorth@2x.png create mode 100644 resources/img/scalawave.png create mode 100644 resources/img/scalawave@2x.png create mode 100644 resources/img/sfscala.png create mode 100644 resources/img/sfscala@2x.png create mode 100644 resources/img/shadow.png create mode 100644 resources/img/smooth-spiral.png create mode 100644 resources/img/smooth-spiral@2x.png create mode 100644 resources/img/splash.png create mode 100644 resources/img/splash@2x.png create mode 100644 resources/img/swiss-alps-sunset3.jpg create mode 100644 resources/img/swiss-alps-sunset5-blurred.jpg create mode 100644 resources/img/swiss-alps-sunset5-dark-overlay.jpg create mode 100644 resources/img/swiss-alps-sunset5-short-blue.jpg create mode 100644 resources/img/swiss-alps-sunset5-short.jpg create mode 100644 resources/img/swiss-alps-sunset5-sm.jpg create mode 100644 resources/img/swiss-alps-sunset5.jpg create mode 100644 resources/img/swiss-flag.png create mode 100644 resources/img/swiss-flag@2x.png create mode 100644 resources/img/test.png create mode 100644 resources/img/transparent_noise.png create mode 100644 resources/img/twitter-logo-blue.png create mode 100644 resources/img/twitter-logo-blue@2x.png create mode 100644 resources/img/twitter-logo-white-lg.png create mode 100644 resources/img/twitter-logo-white-lg@2x.png create mode 100644 resources/img/twitter-logo-white.png create mode 100644 resources/img/twitter-logo-white@2x.png create mode 100644 resources/img/twitter-logo.png create mode 100644 resources/img/type-inf-code.png create mode 100644 resources/img/typelevel.png create mode 100644 resources/img/typelevel@2x.png create mode 100644 resources/img/uberconf2014.png create mode 100644 resources/img/uberconf2014@2x.png create mode 100644 resources/img/view-leman-blurred.jpg create mode 100644 resources/img/view-leman-blurred2.jpg create mode 100644 resources/img/view-leman-gradient-map.jpg create mode 100644 resources/img/view-leman-gradient-map2.jpg create mode 100644 resources/img/view-leman-grayscale.jpg create mode 100644 resources/img/view-leman-opt.jpg create mode 100644 resources/img/view-leman-opt2.jpg create mode 100644 resources/img/view-leman.jpg create mode 100644 resources/img/white-line.png create mode 100644 resources/img/winterretreat2016.png create mode 100644 resources/img/winterretreat2016@2x.png delete mode 100644 resources/javascript/coursera/bargraphs.js delete mode 100644 resources/javascript/coursera/degrees.js delete mode 100644 resources/javascript/coursera/difficulty-by-expertise.png delete mode 100644 resources/javascript/coursera/difficulty-to-expertise.js delete mode 100644 resources/javascript/coursera/difficulty-to-field.js delete mode 100644 resources/javascript/coursera/difficulty.png delete mode 100644 resources/javascript/coursera/editors.js delete mode 100644 resources/javascript/coursera/editors.png delete mode 100644 resources/javascript/coursera/fields-of-study.js delete mode 100644 resources/javascript/coursera/g.pie.js delete mode 100644 resources/javascript/coursera/g.raphael.js delete mode 100644 resources/javascript/coursera/grades-breakdown.js delete mode 100644 resources/javascript/coursera/jquery-jvectormap-1.1.1.min.js delete mode 100644 resources/javascript/coursera/languages.js delete mode 100644 resources/javascript/coursera/languges.png delete mode 100644 resources/javascript/coursera/raphael.js delete mode 100644 resources/javascript/coursera/timespent.png delete mode 100644 resources/javascript/coursera/what-interested-you.js delete mode 100644 resources/javascript/coursera/where-apply.js delete mode 100644 resources/javascript/coursera/whereapply.png delete mode 100644 resources/javascript/coursera/worldmap-density.js delete mode 100644 resources/javascript/coursera/worldmap-population.js delete mode 100644 resources/javascript/coursera/worldmap.js delete mode 100644 resources/javascript/coursera/worthit-followup.png delete mode 100644 resources/javascript/coursera/worthit.png delete mode 100644 resources/javascript/expandingImageMenu.js delete mode 100644 resources/javascript/frontpage.js delete mode 100644 resources/javascript/prettify/prettify.css rename resources/{javascript => js}/bootstrap-dropdown-app.js (100%) rename resources/{javascript => js}/bootstrap-dropdown.js (100%) rename resources/{javascript => js}/bootstrap-popover.js (100%) rename resources/{javascript => js}/bootstrap-twipsy.js (100%) create mode 100644 resources/js/functions.js rename resources/{javascript => js}/jquery.accordionza.js (100%) rename resources/{javascript => js}/jquery.easing.1.3.js (100%) rename resources/{javascript => js}/jquery.easing.js (100%) create mode 100755 resources/js/tweetMachine-update.js create mode 100644 resources/js/vendor/.tweetMachine.js.kate-swp create mode 100644 resources/js/vendor/codemirror/clike.js create mode 100644 resources/js/vendor/codemirror/codemirror.js rename resources/{javascript => js/vendor}/effects.core.js (96%) rename resources/{javascript => js/vendor}/effects.highlight.js (100%) create mode 100644 resources/js/vendor/jekyll.search.min.js create mode 100644 resources/js/vendor/jquery.autocomplete.js rename resources/{javascript => js/vendor}/jquery.js (99%) create mode 100644 resources/js/vendor/jquery.sticky.js create mode 100644 resources/js/vendor/moment.min.js rename resources/{javascript => js/vendor}/moveScroller.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-apollo.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-clj.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-css.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-go.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-hs.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-lisp.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-lua.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-ml.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-n.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-proto.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-scala.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-sql.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-tex.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-vb.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-vhdl.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-wiki.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-xq.js (100%) rename resources/{javascript => js/vendor}/prettify/lang-yaml.js (100%) rename resources/{javascript => js/vendor}/prettify/prettify.js (100%) rename resources/{javascript => js/vendor}/toc.js (78%) create mode 100644 resources/js/vendor/unslider.js delete mode 100644 resources/stylesheets/base.css delete mode 100644 resources/stylesheets/custom.css delete mode 100644 resources/stylesheets/docs.css delete mode 100644 resources/stylesheets/frontpage.css delete mode 100644 resources/stylesheets/pager.css delete mode 100644 resources/stylesheets/prettify.css delete mode 100644 resources/stylesheets/screen.css delete mode 100644 resources/stylesheets/style.css delete mode 100644 resources/stylesheets/syntax.css delete mode 100644 resources/stylesheets/toc.css create mode 100755 scripts/ci.sh delete mode 100644 search.html delete mode 100644 sips/.jekyll-metadata delete mode 100644 sips/README.md delete mode 100644 sips/completed/_posts/2009-06-02-early-member-definitions.md delete mode 100644 sips/completed/_posts/2010-05-06-scala-specialization.md delete mode 100644 sips/completed/_posts/2010-07-20-new-collection-classes.md delete mode 100644 sips/completed/_posts/2011-10-13-string-interpolation.md delete mode 100644 sips/index.md delete mode 100644 sips/minutes-list.md delete mode 100644 sips/pending/_posts/2014-06-27-42.type.md delete mode 100644 sips/pending/_posts/2017-02-07-make-types-behave-like-expressions.md delete mode 100644 sips/pending/futures-promises.html delete mode 100644 sips/pending/implicit-classes.html delete mode 100644 sips/pending/inline-classes.html delete mode 100644 sips/pending/modularizing-language-features.html delete mode 100644 sips/pending/string-interpolation.html delete mode 100644 sips/pending/type-dynamic.html delete mode 100644 sips/pending/value-classes.html delete mode 100644 sips/sip-list.md delete mode 100644 sips/slip-submission.md delete mode 100644 style/index.md delete mode 100644 tutorials/index.md delete mode 100644 tutorials/partest-guide.md delete mode 100644 tutorials/tour/_posts/2017-02-13-higher-order-functions.md delete mode 100644 tutorials/tour/_posts/2017-02-13-implicit-parameters.md delete mode 100644 tutorials/tour/_posts/2017-02-13-mixin-class-composition.md delete mode 100644 tutorials/tour/_posts/2017-02-13-polymorphic-methods.md delete mode 100644 tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md delete mode 100644 tutorials/tour/_posts/2017-02-13-tour-of-scala.md diff --git a/.drone.yml b/.drone.yml index 22fdde9af3..d36025ce89 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,9 +1,6 @@ pipeline: build: - image: scalaplatform/jdk8-ruby2-coursier:0.1 + image: scalacenter/scala-rvm-jvm-coursier:2.0 pull: true commands: - - bundle install - - ./scripts/run-tut.sh - - rm -r tut-tmp - - bundle exec jekyll build + - ./scripts/ci.sh diff --git a/.drone.yml.sig b/.drone.yml.sig index e492c55065..8240a38b07 100644 --- a/.drone.yml.sig +++ b/.drone.yml.sig @@ -1 +1 @@ -eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogc2NhbGFwbGF0Zm9ybS9qZGs4LXJ1YnkyLWNvdXJzaWVyOjAuMQogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.uCV-tIDp9xbL2u2y27B9id6SL89dBfiiiTvVXYxHAbw \ No newline at end of file +eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogamRrLXJ2bS1jb3Vyc2llcjpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIHNvdXJjZSB-Ly5wcm9maWxlCiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.7Rp37FEwRqAo85EdFYZh1PoyU8mxpFdEnpchWaQkHCc diff --git a/.gitignore b/.gitignore index 22a496be82..c73823b558 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ _site +.ruby-version .DS_Store .project .settings @@ -8,3 +9,4 @@ vendor/bundle .idea/ /coursier /tut-tmp/ +.sass-cache/ diff --git a/CNAME b/CNAME deleted file mode 100644 index 4c54828903..0000000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -docs.scala-lang.org \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..948de8e719 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,78 @@ +## Scala Code of Conduct + +We are committed to providing a friendly, safe and welcoming environment for +all, regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, body size, race, ethnicity, +age, religion, nationality, or other such characteristics. + +### Our Standards + +**Whether you’re a regular contributor or a newcomer, we care about making this community a welcoming and safe place for you and we’ve got your back.** + +As a member of the community, you agree to the following: + +**Encouraged:** + +- Be kind and courteous. +- Respect differences of opinion and remember that every design or implementation choice carries a trade-off and numerous costs. There is seldom a single right answer. +- Remember that everyone was new to Scala at some point. We want to encourage newcomers to join our community and learn the Scala language and ecosystem. Assume competence. +- Show empathy towards other community members. + +**Discouraged:** + +- Keep unstructured critique to a minimum. We encourage sharing ideas and perspectives, so please ensure that your feedback is constructive and relevant. If you have solid ideas you want to experiment with, make a fork and see how it works. +- Avoid aggressive and micro-aggressive behavior, such as unconstructive criticism, providing corrections that do not improve the conversation (sometimes referred to as "well actually"s), repeatedly interrupting or talking over someone else, feigning surprise at someone’s lack of knowledge or awareness about a topic, or subtle prejudice (for example, comments like “That’s so easy my grandmother could do it.”). For more examples of this kind of behavior, [see the Recurse Center's user manual](https://www.recurse.com/manual#sec-environment). +- We will exclude you from interaction if you insult, demean or harass anyone. The term “Harassment” includes “Unacceptable Behavior” described in the [Citizen Code of Conduct](http://citizencodeofconduct.org/). **In particular, we don’t tolerate behavior that excludes people in socially marginalized groups.** +- Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member's behavior, please contact one of the [moderators](https://contributors.scala-lang.org/about) or any member of the [Scala Center](http://scala.epfl.ch/) immediately. +- Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome. + +### Moderation + +These are the policies for upholding our community’s standards of conduct. If +you feel that a thread needs moderation, please contact anyone on the +[moderation team](https://contributors.scala-lang.org/about), or any employee of +the [Scala Center](https://scala.epfl.ch/). + +- Remarks that violate the above code of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) +- Moderators will warn users who make remarks inconsistent with the above code of conduct. +- If the warning is unheeded, the user will be “kicked,” i.e., kicked out of the communication channel to cool off. +- If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded. +- Moderators may choose at their discretion to un-ban the user if it was a first offense and they if they make suitable amends with the offended party. +- If you think a ban is unjustified, please take it up with that moderator, or with a different moderator, in private. Complaints about bans in-channel are not allowed. +- Moderators are held to a higher standard than other community members. If a moderator acts inappropriately, they should expect less leeway than others. + +In the Scala community we strive to go the extra step to look out for each +other. Don’t just aim to be technically unimpeachable; try to be your best self. +In particular, avoid exacerbating offensive or sensitive issues, particularly if +they’re off-topic; this all too often leads to unnecessary fights, hurt +feelings, and damaged trust; worse, it can drive people away from the community +entirely. + +If someone takes issue with something you said or did, resist the urge to be +defensive. Rather, stop the offending behavior, apologize, and be sensitive +thereafter. Even if you feel you were misinterpreted or unfairly accused, +chances are good there was something you could’ve communicated better — remember +that it’s your responsibility to make your fellow Scala developers comfortable. +We are all here first and foremost because we want to talk about cool +technology, and everyone wants to get along in doing so. People are generally +eager to assume good intent and forgive. + +### Domain + +The enforcement policies listed above apply to all official Scala channels: +mailing lists, GitHub repositories and Gitter channels under scala and +scalacenter, Discourse, and Scala Center venues and hackathons. For other +projects adopting the Scala Code of Conduct, please contact the maintainers of +those projects for enforcement. If you wish to use this code of conduct for your +own project, consider explicitly mentioning your moderation policy or making a +copy with your own moderation policy so as to avoid confusion. + +### Credits + +Adapted from and/or inspired by multiple successful Codes of Conduct, including: + +* [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html) +* [The Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) +* [The Contributor Covenant v1.4.0](http://contributor-covenant.org/version/1/4/) +* [The Recurse Center's User Manual](https://www.recurse.com/manual#sec-environment) +* [The 18F Code of Conduct](https://18f.gsa.gov/code-of-conduct/) \ No newline at end of file diff --git a/Gemfile b/Gemfile index 37f5eaa42e..896a75036c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,12 @@ source 'https://rubygems.org' -gem 'github-pages', group: :jekyll_plugins +gem 'jekyll-redirect-from' +# gem 'html-proofer' # link-checking: bundle exec htmlproofer ./_site/ --only-4xx --empty-alt-ignore --allow-hash-href + +# group :jekyll_plugins do +# gem 'hawkins' +# end + +# ^ Useful for live reloading the site in your +# browser during development. To use, uncomment +# and do: +# bundle exec jekyll liveserve --incremental diff --git a/Gemfile.lock b/Gemfile.lock index f3afc6d455..122d727d68 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,145 +1,53 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.7) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.4.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.10.0) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) colorator (1.1.0) - ethon (0.9.1) - ffi (>= 1.3.0) - execjs (2.7.0) - faraday (0.9.2) - multipart-post (>= 1.2, < 3) - ffi (1.9.14) + ffi (1.9.18) forwardable-extended (2.6.0) - gemoji (2.1.0) - github-pages (104) - activesupport (= 4.2.7) - github-pages-health-check (= 1.2.0) - jekyll (= 3.3.0) - jekyll-avatar (= 0.4.2) - jekyll-coffeescript (= 1.0.1) - jekyll-feed (= 0.8.0) - jekyll-gist (= 1.4.0) - jekyll-github-metadata (= 2.2.0) - jekyll-mentions (= 1.2.0) - jekyll-paginate (= 1.1.0) - jekyll-redirect-from (= 0.11.0) - jekyll-sass-converter (= 1.3.0) - jekyll-seo-tag (= 2.1.0) - jekyll-sitemap (= 0.12.0) - jekyll-swiss (= 0.4.0) - jemoji (= 0.7.0) - kramdown (= 1.11.1) - liquid (= 3.0.6) - listen (= 3.0.6) - mercenary (~> 0.3) - minima (= 2.0.0) - rouge (= 1.11.1) - terminal-table (~> 1.4) - github-pages-health-check (1.2.0) - addressable (~> 2.3) - net-dns (~> 0.8) - octokit (~> 4.0) - public_suffix (~> 1.4) - typhoeus (~> 0.7) - html-pipeline (2.4.2) - activesupport (>= 2) - nokogiri (>= 1.4) - i18n (0.7.0) - jekyll (3.3.0) + jekyll (3.5.1) addressable (~> 2.4) colorator (~> 1.0) jekyll-sass-converter (~> 1.0) jekyll-watch (~> 1.1) kramdown (~> 1.3) - liquid (~> 3.0) + liquid (~> 4.0) mercenary (~> 0.3.3) pathutil (~> 0.9) rouge (~> 1.7) safe_yaml (~> 1.0) - jekyll-avatar (0.4.2) - jekyll (~> 3.0) - jekyll-coffeescript (1.0.1) - coffee-script (~> 2.2) - jekyll-feed (0.8.0) + jekyll-redirect-from (0.12.1) jekyll (~> 3.3) - jekyll-gist (1.4.0) - octokit (~> 4.2) - jekyll-github-metadata (2.2.0) - jekyll (~> 3.1) - octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.2.0) - activesupport (~> 4.0) - html-pipeline (~> 2.3) - jekyll (~> 3.0) - jekyll-paginate (1.1.0) - jekyll-redirect-from (0.11.0) - jekyll (>= 2.0) - jekyll-sass-converter (1.3.0) - sass (~> 3.2) - jekyll-seo-tag (2.1.0) - jekyll (~> 3.3) - jekyll-sitemap (0.12.0) - jekyll (~> 3.3) - jekyll-swiss (0.4.0) + jekyll-sass-converter (1.5.0) + sass (~> 3.4) jekyll-watch (1.5.0) listen (~> 3.0, < 3.1) - jemoji (0.7.0) - activesupport (~> 4.0) - gemoji (~> 2.0) - html-pipeline (~> 2.2) - jekyll (>= 3.0) - json (1.8.3) - kramdown (1.11.1) - liquid (3.0.6) - listen (3.0.6) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9.7) + kramdown (1.14.0) + liquid (4.0.0) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) mercenary (0.3.6) - mini_portile2 (2.1.0) - minima (2.0.0) - minitest (5.9.1) - multipart-post (2.0.0) - net-dns (0.8.0) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) - octokit (4.4.1) - sawyer (~> 0.7.0, >= 0.5.3) pathutil (0.14.0) forwardable-extended (~> 2.6) - public_suffix (1.5.3) - rb-fsevent (0.9.8) - rb-inotify (0.9.7) - ffi (>= 0.5.0) + public_suffix (2.0.5) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) rouge (1.11.1) safe_yaml (1.0.4) - sass (3.4.22) - sawyer (0.7.0) - addressable (>= 2.3.5, < 2.5) - faraday (~> 0.8, < 0.10) - terminal-table (1.7.3) - unicode-display_width (~> 1.1.1) - thread_safe (0.3.5) - typhoeus (0.8.0) - ethon (>= 0.8.0) - tzinfo (1.2.2) - thread_safe (~> 0.1) - unicode-display_width (1.1.1) + sass (3.5.1) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) PLATFORMS ruby DEPENDENCIES - github-pages + jekyll-redirect-from BUNDLED WITH - 1.13.6 + 1.15.4 diff --git a/README.md b/README.md index 356ab5c4b1..6dccfec463 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,19 @@ # Scala Documentation # -[![Build Status](https://platform-ci.scala-lang.org/api/badges/scala/scala.github.com/status.svg)](https://platform-ci.scala-lang.org/scala/scala.github.com) + +[![Build Status](https://platform-ci.scala-lang.org/api/badges/scala/docs.scala-lang/status.svg)](https://platform-ci.scala-lang.org/scala/docs.scala-lang) This repository contains the source for the Scala documentation website, as well as the source for "Scala Improvement Process" (SIP) documents. +## Quickstart ## + +To build and view the site locally: + + gem install bundler + bundle install + bundle exec jekyll serve -I + +For more details, read on. + ## Contributing ## Please have a look at [http://docs.scala-lang.org/contribute.html](http://docs.scala-lang.org/contribute.html) before making a contribution. diff --git a/ba/cheatsheets/index.md b/_ba/cheatsheets/index.md similarity index 97% rename from ba/cheatsheets/index.md rename to _ba/cheatsheets/index.md index e336e31a23..0a7e59790f 100644 --- a/ba/cheatsheets/index.md +++ b/_ba/cheatsheets/index.md @@ -1,16 +1,18 @@ --- layout: cheatsheet -istranslation: true title: Scalacheat + +partof: cheatsheet + by: Brendan O'Connor about: Zahvaljujući Brendan O'Connoru ovaj cheatsheet teži da bude kratki pregled sintakse Scale. Licenca pripada Brendan O'Connor-u, pod CC-BY-SA 3.0 licencom. + language: ba --- ###### Doprinio {{ page.by }} +{{ page.about }} -| | | -| ------ | ------ | | varijable | | | `var x = 5` | varijabla. | | Dobro `val x = 5`
Loše `x=6` | konstanta. | diff --git a/_ba/tour/abstract-types.md b/_ba/tour/abstract-types.md new file mode 100644 index 0000000000..10aa2d7d41 --- /dev/null +++ b/_ba/tour/abstract-types.md @@ -0,0 +1,86 @@ +--- +layout: tour +title: Apstraktni tipovi +language: ba + +discourse: true + +partof: scala-tour + +num: 23 +next-page: compound-types +previous-page: inner-classes +prerequisite-knowledge: variance, upper-type-bound + +--- + +Trejtovi i apstraktne klase mogu imati apstraktne tipove kao članove. +To znači da konkretne implementacije definišu stvarni tip. +Slijedi primjer: + +```tut +trait Buffer { + type T + val element: T +} +``` + +U gornjem primjeru smo definisali apstraktni tip `T`. +On se koristi za opis člana `element`. +Ovaj trejt možemo naslijediti u apstraktnoj klasi i dodati gornju granicu tipa za `T` da bi ga učinili preciznijim. + +```tut +abstract class SeqBuffer extends Buffer { + type U + type T <: Seq[U] + def length = element.length +} +``` + +Primijetite da možemo koristiti još jedan apstraktni tip, `U`, kao gornju granicu tipa. Klasa `SeqBuffer` omogućuje čuvanje samo sekvenci u baferu kazivanjem da tip `T` +mora biti podtip `Seq[U]` za neki novi apstraktni tip `U`. + +Trejtovi ili [klase](classes.html) s apstraktnim tip-članovima se često koriste u kombinaciji s instanciranjem anonimnih klasa. +Radi ilustracije, pogledaćemo program koji radi s sekvencijalnim baferom koji sadrži listu integera: + +```tut +abstract class IntSeqBuffer extends SeqBuffer { + type U = Int +} + + +def newIntSeqBuf(elem1: Int, elem2: Int): IntSeqBuffer = + new IntSeqBuffer { + type T = List[U] + val element = List(elem1, elem2) + } +val buf = newIntSeqBuf(7, 8) +println("length = " + buf.length) +println("content = " + buf.element) +``` + +Metoda `newIntSeqBuf` koristi anonimnu klasu kao implementaciju `IntSeqBuf` postavljanjem tipa `T` u `List[Int]`. + +Često je moguće pretvoriti apstraktni tip-član u tipski parametar klase i obrnuto. +Slijedi verzija gornjeg koda koji koristi tipske parametre: + +```tut +abstract class Buffer[+T] { + val element: T +} +abstract class SeqBuffer[U, +T <: Seq[U]] extends Buffer[T] { + def length = element.length +} + +def newIntSeqBuf(e1: Int, e2: Int): SeqBuffer[Int, Seq[Int]] = + new SeqBuffer[Int, List[Int]] { + val element = List(e1, e2) + } + +val buf = newIntSeqBuf(7, 8) +println("length = " + buf.length) +println("content = " + buf.element) +``` + +Primijetite da moramo koristiti [anotacije za varijansu](variances.html) ovdje (`+T <: Seq[U]`) da sakrijemo konkretni tip sekvencijalne implementacije objekta vraćenog iz metode `newIntSeqBuf`. +Nadalje, postoje slučajevi u kojima nije moguće zamijeniti apstraktne tipove tip parametrima. diff --git a/_ba/tour/annotations.md b/_ba/tour/annotations.md new file mode 100644 index 0000000000..2040c97626 --- /dev/null +++ b/_ba/tour/annotations.md @@ -0,0 +1,138 @@ +--- +layout: tour +title: Anotacije +language: ba + +discourse: true + +partof: scala-tour + +num: 32 +next-page: default-parameter-values +previous-page: by-name-parameters + +--- + +Anotacije pridružuju meta-informacije definicijama. +Npr, anotacija `@deprecated` prije metode tjera kompajler da ispište upozorenje ako se metoda koristi. +``` +object DeprecationDemo extends App { + @deprecated + def hello = "hola" + + hello +} +``` +Ovo će se kompajlirati ali će kompajler ispisati upozorenje: "there was one deprecation warning". + +Anotacijska klauza odnosi se na prvu definiciju ili deklaraciju koja slijedi nakon nje. +Anotacijskih klauza može biti i više od jedne. +Redoslijed anotacijskih klauza nije bitan. + +## Anotacije za korektnost enkodiranja +Određene anotacije će uzrokovati pad kompajliranja ako određeni uslovi nisu ispunjeni. +Npr, anotacija `@tailrec` osigurava da je metoda [tail-rekurzivna](https://en.wikipedia.org/wiki/Tail_call). Tail-rekurzija može zadržati memorijske zahtjeve konstantnim. +Evo kako se koristi na metodi koja izračunava faktorijel: +```tut +import scala.annotation.tailrec + +def factorial(x: Int): Int = { + + @tailrec + def factorialHelper(x: Int, accumulator: Int): Int = { + if (x == 1) accumulator else factorialHelper(x - 1, accumulator * x) + } + factorialHelper(x, 1) +} +``` +Metoda `factorialHelper` ima `@tailrec` koja osigurava da je metoda zaista tail-rekurzivna. Ako bismo promijenili implementaciju `factorialHelper` na sljedeće, palo bi: +``` +import scala.annotation.tailrec + +def factorial(x: Int): Int = { + @tailrec + def factorialHelper(x: Int): Int = { + if (x == 1) 1 else x * factorialHelper(x - 1) + } + factorialHelper(x) +} +``` +Dobili bismo poruku "Recursive call not in tail position". + + +## Anotacije koje utiču na generisanje koda + +Neke anotacije kao što je `@inline` utiču na generisanje koda (npr. Vaš jar fajl može imati drugačije bajtove ako ne koristite anotaciju). Inlining znači ubacivanje koda u tijelo metode na mjestu poziva. Rezultujući bajtkod je duži, ali bi trebao da radi brže. +Koristeći anotaciju `@inline` ne osigurava da će metoda biti inline, ali će uzrokovati da to kompajler odradi ako heuristička analiza bude zadovoljavajuća. + +### Java anotacije ### + +Kada se piše Scala kod koji radi sa Javom, postoji par razlika u sintaksi anotacija. +**Napomena:** Pobrinite se da koristite `-target:jvm-1.8` opciju sa Java anotacijama. + +Java ima korisnički definisane metapodatke u formi [anotacija](https://docs.oracle.com/javase/tutorial/java/annotations/). Ključna sposobnost anotacija je da koriste parove ime-vrijednost za inicijalizaciju svojih elemenata. Naprimjer, ako nam treba anotacija da pratimo izvor neke klase mogli bismo je definisati kao + +``` +@interface Source { + public String URL(); + public String mail(); +} +``` + +I upotrijebiti je ovako: + +``` +@Source(URL = "http://coders.com/", + mail = "support@coders.com") +public class MyClass extends HisClass ... +``` + +Primjena anotacije u Scali izgleda kao poziv konstruktora, dok se za instanciranje Javinih anotacija moraju koristiti imenovani argumenti: + +``` +@Source(URL = "http://coders.com/", + mail = "support@coders.com") +class MyScalaClass ... +``` + +Ova sintaksa je ponekad naporna, npr. ako anotacija ima samo jedan element (bez podrazumijevane vrijednosti), pa po konvenciji, +ako se koristi naziv `value` onda se u Javi može koristiti i konstruktor-sintaksa: + +``` +@interface SourceURL { + public String value(); + public String mail() default ""; +} +``` + +I upotrijebiti je kao: + +``` +@SourceURL("http://coders.com/") +public class MyClass extends HisClass ... +``` + +U ovom slučaju, Scala omogućuje istu sintaksu: + +``` +@SourceURL("http://coders.com/") +class MyScalaClass ... +``` + +Element `mail` je specificiran s podrazumijevanom vrijednošću tako da ne moramo eksplicitno navoditi vrijednost za njega. +Međutim, ako trebamo, ne možemo miješati dva Javina stila: + +``` +@SourceURL(value = "http://coders.com/", + mail = "support@coders.com") +public class MyClass extends HisClass ... +``` + +Scala omogućuje veću fleksibilnost u ovom pogledu: + +``` +@SourceURL("http://coders.com/", + mail = "support@coders.com") + class MyScalaClass ... +``` + diff --git a/_ba/tour/basics.md b/_ba/tour/basics.md new file mode 100644 index 0000000000..24f006f791 --- /dev/null +++ b/_ba/tour/basics.md @@ -0,0 +1,315 @@ +--- +layout: tour +title: Osnove +language: ba + +discourse: true + +partof: scala-tour + +num: 2 +next-page: unified-types +previous-page: tour-of-scala + +--- + +Na ovoj stranici ćemo objasniti osnove Scale. + +## Probavanje Scale u browseru + +Scalu možete probati u Vašem browser sa ScalaFiddle aplikacijom. + +1. Idite na [https://scalafiddle.io](https://scalafiddle.io). +2. Zalijepite `println("Hello, world!")` u lijevi panel. +3. Kliknite "Run" dugme. Izlaz će se pojaviti u desnom panelu. + +Ovo je jednostavan način za eksperimentisanje sa Scala kodom. + +## Izrazi (en. expressions) + +Izrazi su izjave koje imaju vrijednost. +``` +1 + 1 +``` +Rezultate izraza možete prikazati pomoću `println`. + +```tut +println(1) // 1 +println(1 + 1) // 2 +println("Hello!") // Hello! +println("Hello," + " world!") // Hello, world! +``` + +### Vrijednosti + +Rezultatima možete dodijeliti naziv pomoću ključne riječi `val`. + +```tut +val x = 1 + 1 +println(x) // 2 +``` + +Imenovani rezultati, kao `x` ovdje, nazivaju se vrijednostima. +Referenciranje vrijednosti ne okida njeno ponovno izračunavanje. + +Vrijednosti se ne mogu mijenjati. + +```tut:nofail +val x = 1 + 1 +x = 3 // Ovo se ne kompajlira. +``` + +Tipovi vrijednosti mogu biti (automatski) zaključeni, ali možete i eksplicitno navesti tip: + +```tut +val x: Int = 1 + 1 +``` + +Primijetite da deklaracija tipa `Int` dolazi nakon identifikatora `x`. Također morate dodati i `:`. + +### Varijable + +Varijable su kao vrijednosti, osim što ih možete promijeniti. Varijable se definišu ključnom riječju `var`. + +```tut +var x = 1 + 1 +x = 3 // Ovo se kompajlira jer je "x" deklarisano s "var" ključnom riječju. +println(x * x) // 9 +``` + +Kao i s vrijednostima, tip možete eksplicitno navesti ako želite: + +```tut +var x: Int = 1 + 1 +``` + + +## Blokovi + +Izraze možete kombinovati okružujući ih s `{}`. Ovo se naziva blok. + +Rezultat zadnjeg izraza u bloku je rezultat cijelog bloka, također. + +```tut +println({ + val x = 1 + 1 + x + 1 +}) // 3 +``` + +## Funkcije + +Funkcije su izrazi koji primaju parametre. + +Možete definisati anonimnu funkciju (bez imena) koja vraća cijeli broj plus jedan: + +```tut +(x: Int) => x + 1 +``` + +Na lijevoj strani `=>` je lista parametara. Na desnoj strani je izraz koji koristi date parametre. + +Funkcije možete i imenovati. + +```tut +val addOne = (x: Int) => x + 1 +println(addOne(1)) // 2 +``` + +Funkcije mogu imati više parametara. + +```tut +val add = (x: Int, y: Int) => x + y +println(add(1, 2)) // 3 +``` + +Ili bez parametara. + +```tut +val getTheAnswer = () => 42 +println(getTheAnswer()) // 42 +``` + +## Metode + +Metode izgledaju i ponašaju se vrlo slično funkcijama, ali postoji nekoliko razlika između njih. + +Metode se definišu ključnom riječju `def`. Nakon `def` slijedi naziv, lista parametara, povratni tip, i tijelo. + +```tut +def add(x: Int, y: Int): Int = x + y +println(add(1, 2)) // 3 +``` + +Primijetite da je povratni tip deklarisan _nakon_ liste parametara i dvotačke `: Int`. + +Metode mogu imati više listi parametara. + +```tut +def addThenMultiply(x: Int, y: Int)(multiplier: Int): Int = (x + y) * multiplier +println(addThenMultiply(1, 2)(3)) // 9 +``` + +Ili bez listi parametara ikako. + +```tut +def name: String = System.getProperty("name") +println("Hello, " + name + "!") +``` + +Postoje i neke druge razlike, ali zasad, možete misliti o njima kao nečemu sličnom funkcijama. + +Metode mogu imati višelinijske izraze također. +```tut +def getSquareString(input: Double): String = { + val square = input * input + square.toString +} +``` +Zadnjo izraz u tijelu metode je povratna vrijednost metode. (Scala ima ključnu riječ `return`, ali se rijetko koristi.) + +## Klase + +Klasu možete definisati ključnom riječju `class` praćenom imenom i parametrima konstruktora. + +```tut +class Greeter(prefix: String, suffix: String) { + def greet(name: String): Unit = + println(prefix + name + suffix) +} +``` +Povratni tip metode `greet` je `Unit`, koji kaže da metoda ne vraća ništa značajno. +Koristi se slično kao `void` u Javi ili C-u. +(Razlika je u tome što svaki Scalin izraz mora imati neku vrijednost, postoji singlton vrijednost tipa `Unit`, piše se `()`. +Ne prenosi nikakvu korisnu informaciju.) + +Instancu klase možete kreirati pomoću ključne riječi `new`. + +```tut +val greeter = new Greeter("Hello, ", "!") +greeter.greet("Scala developer") // Hello, Scala developer! +``` + +Detaljniji pregled klasa biće dat [kasnije](classes.html). + +## Case klase + +Scala ima poseban tip klase koji se zove "case" klasa. +Po defaultu, case klase su nepromjenjive i porede se po vrijednosti. Možete ih definisati s `case class` ključnim riječima. + +```tut +case class Point(x: Int, y: Int) +``` + +Instancu case klase možete kreirati i bez ključne riječi `new`. + +```tut +val point = Point(1, 2) +val anotherPoint = Point(1, 2) +val yetAnotherPoint = Point(2, 2) +``` + +I porede se po vrijednosti. + +```tut +if (point == anotherPoint) { + println(point + " and " + anotherPoint + " are the same.") +} else { + println(point + " and " + anotherPoint + " are different.") +} +// Point(1,2) i Point(1,2) su iste. + +if (point == yetAnotherPoint) { + println(point + " and " + yetAnotherPoint + " are the same.") +} else { + println(point + " and " + yetAnotherPoint + " are different.") +} +// Point(1,2) su Point(2,2) različite. +``` + +Ima još mnogo stvari vezanih za case klase koje bismo voljeli objasniti, i ubijeđeni smo da ćete se zaljubiti u njih! 0 +Objasnićemo ih u dubinu [kasnije](case-classes.html). + +## Objekti + + +Objekti su jedine instance svojih definicija. Možete misliti o njima kao singltonima svoje vlastite klase. +Objekte možete definisati ključnom riječju `object`. + +```tut +object IdFactory { + private var counter = 0 + def create(): Int = { + counter += 1 + counter + } +} +``` + +Objektima možete pristupati referenciranjem njihovog imena. + +```tut +val newId: Int = IdFactory.create() +println(newId) // 1 +val newerId: Int = IdFactory.create() +println(newerId) // 2 +``` + +Objekti će biti objašnjeni u dubinu [kasnije](singleton-objects.html). + +## Trejtovi + +Trejtovi su tipovi koji sadrže polja i metode. Više trejtova se može kombinovati. + +Definišu se pomoću `trait` ključne riječi. + +```tut +trait Greeter { + def greet(name: String): Unit +} +``` + +Metode trejtova mogu imati defaultnu implementaciju. + +```tut +trait Greeter { + def greet(name: String): Unit = + println("Hello, " + name + "!") +} +``` + +Možete naslijediti trejtove s `extends` ključnom riječi i redefinisati (override) implementacije s `override` ključnom riječi. + +```tut +class DefaultGreeter extends Greeter + +class CustomizableGreeter(prefix: String, postfix: String) extends Greeter { + override def greet(name: String): Unit = { + println(prefix + name + postfix) + } +} + +val greeter = new DefaultGreeter() +greeter.greet("Scala developer") // Hello, Scala developer! + +val customGreeter = new CustomizableGreeter("How are you, ", "?") +customGreeter.greet("Scala developer") // How are you, Scala developer? +``` + +Ovdje, `DefaultGreeter` nasljeđuje samo jedan trejt, ali može naslijediti više njih. + +Trejtove ćemo pokriti u dubinu [kasnije](traits.html). + +## Glavna metoda + +Glavna metoda je ulazna tačka programa. +Java Virtuelna Mašina traži da se glavna metoda zove `main` i da prima jedan argument, niz stringova. + +Koristeći objekt, možete definisati glavnu metodu ovako: + +```tut +object Main { + def main(args: Array[String]): Unit = + println("Hello, Scala developer!") +} +``` diff --git a/_ba/tour/by-name-parameters.md b/_ba/tour/by-name-parameters.md new file mode 100644 index 0000000000..4a46335095 --- /dev/null +++ b/_ba/tour/by-name-parameters.md @@ -0,0 +1,49 @@ +--- +layout: tour +title: By-name parametri +language: ba + +discourse: true + +partof: scala-tour + +num: 31 +next-page: annotations +previous-page: operators + +--- + +_By-name parametri_ (u slobodnom prevodu "po-imenu parametri") se izračunavaju samo kada se koriste. +Oni su kontrastu sa _by-value parametrima_ ("po-vrijednosti parametri"). +Da bi parametar bio pozivan by-name, dodajte `=>` prije njegovog tipa. +```tut +def calculate(input: => Int) = input * 37 +``` +By-name parametri imaju prednost da se ne izračunavaju ako se ne koriste u tijelu funkcije. +U drugu ruku, by-value parametri imaju prednost da se izračunavaju samo jednom. + +Ovo je primjer kako bi mogli implementirati while petlju: + +```tut +def whileLoop(condition: => Boolean)(body: => Unit): Unit = + if (condition) { + body + whileLoop(condition)(body) + } + +var i = 2 + +whileLoop (i > 0) { + println(i) + i -= 1 +} // prints 2 1 +``` +Metoda `whileLoop` koristi višestruke liste parametarada bi uzela uslov i tijelo petlje. +Ako je `condition` true, `body` se izvrši i zatim rekurzivno poziva `whileLoop`. +Ako je `condition` false, `body` se ne izračunava jer smo dodali `=>` prije tipa od `body`. + +Kada proslijedimo `i > 0` kao naš `condition` i `println(i); i-= 1` kao `body`, +ponaša se kao obična while petlja mnogih jezika. + +Ova mogućnost da se odgodi izračunavanje parametra dok se ne koristi može poboljšati performanse ako je parametar +skup za izračunavanje ili blok koda koji dugo traje kao npr. dobavljanje URL-a. diff --git a/_ba/tour/case-classes.md b/_ba/tour/case-classes.md new file mode 100644 index 0000000000..84fdc68c98 --- /dev/null +++ b/_ba/tour/case-classes.md @@ -0,0 +1,63 @@ +--- +layout: tour +title: Case klase +language: ba + +discourse: true + +partof: scala-tour + +num: 11 +next-page: pattern-matching +previous-page: currying +prerequisite-knowledge: classes, basics, mutability + +--- + +Case klase su kao obične klase s par ključnih razlika. +Dobre su za modelovanje nepromjenjivih podataka. +U sljedećem koraku turneje, vidjećemo kako su korisne u [podudaranju uzoraka (pattern matching)](pattern-matching.html). + +## Definisanje case klase +Minimalna case klasa se sastoji iz ključnih riječi `case class`, identifikatora, i liste parametara (koja može biti prazna): +```tut +case class Book(isbn: String) + +val frankenstein = Book("978-0486282114") +``` +Primijetite kako se ključna riječ `new` ne koristi za instanciranje `Book` case klase. To je zato što case klase imaju podrazumijevanu `apply` metodu koja se brine o instanciranju. + +Kada kreirate case klasu s parametrima, parametri su public `val`. +``` +case class Message(sender: String, recipient: String, body: String) +val message1 = Message("guillaume@quebec.ca", "jorge@catalonia.es", "Ça va ?") + +println(message1.sender) // prints guillaume@quebec.ca +message1.sender = "travis@washington.us" // this line does not compile +``` +Ne možete izmijetniti `message1.sender` zato što je `val` (tj. nepromjenjiv). Moguće je koristiti i `var` u case klasama ali nije preporučeno. + +## Poređenje +Case klase se porede po strukturi a ne po referenci: +``` +case class Message(sender: String, recipient: String, body: String) + +val message2 = Message("jorge@catalonia.es", "guillaume@quebec.ca", "Com va?") +val message3 = Message("jorge@catalonia.es", "guillaume@quebec.ca", "Com va?") +val messagesAreTheSame = message2 == message3 // true +``` +Iako se `message2` i `message3` odnose na različite objekte, vrijednost oba objekta je ista. + +## Kopiranje +Možete kreirati (plitku) kopiju instance case klase koristeći `copy` metodu. Opciono možete promijeniti argumente konstruktora. + +``` +case class Message(sender: String, recipient: String, body: String) +val message4 = Message("julien@bretagne.fr", "travis@washington.us", "Me zo o komz gant ma amezeg") +val message5 = message4.copy(sender = message4.recipient, recipient = "claire@bourgogne.fr") +message5.sender // travis@washington.us +message5.recipient // claire@bourgogne.fr +message5.body // "Me zo o komz gant ma amezeg" +``` + +`recipient` od `message4` se koristi kao `sender` od `message5` ali je `body` od `message4` kopiran direktno. diff --git a/_ba/tour/classes.md b/_ba/tour/classes.md new file mode 100644 index 0000000000..aa5c36068c --- /dev/null +++ b/_ba/tour/classes.md @@ -0,0 +1,125 @@ +--- +layout: tour +title: Klase +language: ba + +discourse: true + +partof: scala-tour + +num: 4 +next-page: traits +previous-page: unified-types +topics: classes +prerequisite-knowledge: no-return-keyword, type-declaration-syntax, string-interpolation, procedures + +--- + +Klase u Scali su šabloni za kreiranje objekata. +Mogu sadržavati metode, vrijednosti, varijable, tipove, objekte, trejtove i klase koji se kolektivno zovu _članovi_. +Tipovi, objekti i trejtovi biće pokriveni kasnije. + +## Definisanje klase +Minimalna definicija klase sastoji se od riječi `class` i identifikatora. Imena klasa bi trebala počinjati velikim slovom. +```tut +class User + +val user1 = new User +``` +Ključna riječ `new` koristi se za kreiranje instance klase. +`User` ima podrazumijevani konstruktor bez argumenata jer nijedan konstruktor nije definisan. +Međutim, često ćete imati konstruktor i tijelo klase. +Slijedi definicija klase `Point` (en. tačka): + +```tut +class Point(var x: Int, var y: Int) { + + def move(dx: Int, dy: Int): Unit = { + x = x + dx + y = y + dy + } + + override def toString: String = + s"($x, $y)" +} + +val point1 = new Point(2, 3) +point1.x // 2 +println(point1) // prints (x, y) +``` + +Ova klasa ima četiri člana: varijable `x` i `y`, i metode `move` i `toString`. +Za razliku od većine ostalih jezika, primarni konstruktor je sadržan u potpisu klase `(var x: Int, var y: Int)`. +Metoda `move` prima dva cjelobrojna argumenta i vraća `Unit` vrijednost, `()`. +Ovo otprilike odgovara `void`-u u jezicima sličnim Javi. +`toString`, za razliku, ne prima nikakve parametre ali vraća `String` vrijednost. +Pošto `toString` prebrisava metodu `toString` iz [`AnyRef`](unified-types.html), mora biti tagovana s `override`. + +## Konstruktori + +Konstruktori mogu imati opcione parametre koristeći podrazumijevane vrijednosti: + +```tut +class Point(var x: Int = 0, var y: Int = 0) + +val origin = new Point // x and y are both set to 0 +val point1 = new Point(1) +println(point1.x) // prints 1 + +``` + +U ovoj verziji klase `Point`, `x` i `y` imaju podrazumijevanu vrijednost `0` tako da ne morate proslijediti argumente. +Međutim, pošto se argumenti konstruktora čitaju s lijeva na desno, ako želite proslijediti samo `y` vrijednost, morate imenovati parametar. +``` +class Point(var x: Int = 0, var y: Int = 0) +val point2 = new Point(y=2) +println(point2.y) // prints 2 +``` + +Ovo je također dobra praksa zbog poboljšanja čitljivosti. + +## Privatni članovi i sintaksa getera/setera +Članovi su javni (`public`) po defaultu. +Koristite `private` modifikator pristupa da sakrijete članove klase. +```tut +class Point { + private var _x = 0 + private var _y = 0 + private val bound = 100 + + def x = _x + def x_= (newValue: Int): Unit = { + if (newValue < bound) _x = newValue else printWarning + } + + def y = _y + def y_= (newValue: Int): Unit = { + if (newValue < bound) _y = newValue else printWarning + } + + private def printWarning = println("WARNING: Out of bounds") +} + +val point1 = new Point +point1.x = 99 +point1.y = 101 // prints the warning +``` +U ovoj verziji klase `Point`, podaci su spremljeni u privatnim varijablama `_x` i `_y`. +Metode `def x` i `def y` se koriste za njihov pristup. +`def x_=` i `def y_=` se koriste za validaciju i postavljanje vrijednosti `_x` i `_y`. +Primijetite specijalnu sintaksu za setere: metoda ima `_=` nadodano na identifikator getera a parametri dolaze poslije. + +Parametri primarnog konstruktora s `val` i `var` su javni. +Međutim, pošto su `val` nepromjenjivi, ne možete napisati sljedeće. +``` +class Point(val x: Int, val y: Int) +val point = new Point(1, 2) +point.x = 3 // <-- does not compile +``` + +Parametri bez `val` ili `var` su privatne vrijednosti, vidljive samo unutar klase. +``` +class Point(x: Int, y: Int) +val point = new Point(1, 2) +point.x // <-- does not compile +``` diff --git a/ba/tutorials/tour/_posts/2017-02-13-compound-types.md b/_ba/tour/compound-types.md similarity index 69% rename from ba/tutorials/tour/_posts/2017-02-13-compound-types.md rename to _ba/tour/compound-types.md index df41b94c04..8f84b72176 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-compound-types.md +++ b/_ba/tour/compound-types.md @@ -1,14 +1,16 @@ --- -layout: tutorial +layout: tour title: Složeni tipovi +language: ba -disqus: true +discourse: true + +partof: scala-tour + +num: 24 +next-page: self-types +previous-page: abstract-types -tutorial: scala-tour -categories: tour -num: 23 -outof: 33 -language: ba --- Ponekad je potrebno izraziti da je tip objekta podtip nekoliko drugih tipova. @@ -16,22 +18,26 @@ U Scali ovo može biti izraženo pomoću *složenih tipova*, koji su presjeci ti Pretpostavimo da imamo dva trejta: `Cloneable` i `Resetable`: - trait Cloneable extends java.lang.Cloneable { - override def clone(): Cloneable = { - super.clone().asInstanceOf[Cloneable] - } - } - trait Resetable { - def reset: Unit - } +```tut +trait Cloneable extends java.lang.Cloneable { + override def clone(): Cloneable = { + super.clone().asInstanceOf[Cloneable] + } +} +trait Resetable { + def reset: Unit +} +``` Pretpostavimo da želimo napisati funkciju `cloneAndReset` koja prima objekt, klonira ga i resetuje originalni objekt: - def cloneAndReset(obj: ?): Cloneable = { - val cloned = obj.clone() - obj.reset - cloned - } +``` +def cloneAndReset(obj: ?): Cloneable = { + val cloned = obj.clone() + obj.reset + cloned +} +``` Postavlja se pitanje koji bi trebao biti tip parametra `obj`. Ako je `Cloneable` onda objekt može biti `clone`-iran, ali ne i `reset`-ovan; @@ -41,9 +47,11 @@ Ovaj složeni tip u Scali se piše kao: `Cloneable with Resetable`. Ovo je ažurirana funkcija: - def cloneAndReset(obj: Cloneable with Resetable): Cloneable = { - //... - } +``` +def cloneAndReset(obj: Cloneable with Resetable): Cloneable = { + //... +} +``` Složeni tipovi mogu se sastojati od više tipova i mogu imati jednu rafinaciju koja može biti korištena da suzi potpis postojećih članova objekta. General forma je: `A with B with C ... { refinement }` diff --git a/_ba/tour/currying.md b/_ba/tour/currying.md new file mode 100644 index 0000000000..ba0042557c --- /dev/null +++ b/_ba/tour/currying.md @@ -0,0 +1,47 @@ +--- +layout: tour +title: Curry-jevanje +language: ba + +discourse: true + +partof: scala-tour + +num: 10 +next-page: case-classes +previous-page: nested-functions + +--- + +Metode mogu definisati više listi parametara. +Kada je metoda pozvana s manje listi parametara nego što ima, +onda će to vratiti funkciju koja prima preostale liste parametara kao argumente. + +Primjer: + +```tut +object CurryTest extends App { + + def filter(xs: List[Int], p: Int => Boolean): List[Int] = + if (xs.isEmpty) xs + else if (p(xs.head)) xs.head :: filter(xs.tail, p) + else filter(xs.tail, p) + + def modN(n: Int)(x: Int) = ((x % n) == 0) + + val nums = List(1, 2, 3, 4, 5, 6, 7, 8) + println(filter(nums, modN(2))) + println(filter(nums, modN(3))) +} +``` + +_Napomena: metoda `modN` je parcijalno primijenjena u dva poziva `filter`; tj. samo prvi argument je ustvari primijenjen. +Izraz `modN(2)` vraća funkciju tipa `Int => Boolean` i zato je mogući kandidat za drugi argument funkcije `filter`._ + +Rezultat gornjeg programa: + +``` +List(2,4,6,8) +List(3,6) +``` + diff --git a/_ba/tour/default-parameter-values.md b/_ba/tour/default-parameter-values.md new file mode 100644 index 0000000000..2071d3a661 --- /dev/null +++ b/_ba/tour/default-parameter-values.md @@ -0,0 +1,49 @@ +--- +layout: tour +title: Podrazumijevane vrijednosti parametara +language: ba + +discourse: true + +partof: scala-tour + +num: 33 +next-page: named-arguments +previous-page: annotations +prerequisite-knowledge: named-arguments, function syntax + +--- + +Scala omogućuje davanje podrazumijevanih vrijednosti parametrima koje dozvoljavaju korisniku metode da izostavi te parametre. + +```tut +def log(message: String, level: String = "INFO") = println(s"$level: $message") + +log("System starting") // prints INFO: System starting +log("User not found", "WARNING") // prints WARNING: User not found +``` + +Parametar `level` ima podrazumijevanu vrijednost tako da je opcioni. Na zadnjoj liniji, argument `"WARNING"` prebrisava podrazumijevani argument `"INFO"`. Gdje biste koristili overloadane metode u Javi, možete koristiti metode s opcionim parametrima da biste postigli isti efekat. Međutim, ako korisnik izostavi argument, bilo koji sljedeći argumenti moraju biti imenovani. + +```tut +class Point(val x: Double = 0, val y: Double = 0) + +val point1 = new Point(y = 1) +``` +Ovdje moramo reći `y = 1`. + +Podrazumijevani parametri u Scali nisu opcioni kada se koriste iz Java koda: + +```tut +// Point.scala +class Point(val x: Double = 0, val y: Double = 0) +``` + +```java +// Main.java +public class Main { + public static void main(String[] args) { + Point point = new Point(1); // does not compile + } +} +``` diff --git a/_ba/tour/extractor-objects.md b/_ba/tour/extractor-objects.md new file mode 100644 index 0000000000..7aef9bd432 --- /dev/null +++ b/_ba/tour/extractor-objects.md @@ -0,0 +1,67 @@ +--- +layout: tour +title: Ekstraktor objekti +language: ba + +discourse: true + +partof: scala-tour + +num: 16 +next-page: for-comprehensions +previous-page: regular-expression-patterns + +--- + +Ekstraktor objekat je objekat koji ima `unapply` metodu. +Dok je `apply` metoda kao konstruktor koji uzima argumente i kreira objekat, `unapply` metoda prima objekat i pokušava vratiti argumente. +Ovo se najčešće koristi u podudaranju uzoraka i parcijalnim funkcijama. + +```tut +import scala.util.Random + +object CustomerID { + + def apply(name: String) = s"$name--${Random.nextLong}" + + def unapply(customerID: String): Option[String] = { + val name = customerID.split("--").head + if (name.nonEmpty) Some(name) else None + } +} + +val customer1ID = CustomerID("Sukyoung") // Sukyoung--23098234908 +customer1ID match { + case CustomerID(name) => println(name) // prints Sukyoung + case _ => println("Could not extract a CustomerID") +} +``` + +Metoda `apply` kreira `CustomerID` string od argumenta `name`. +Metoda `unapply` radi suprotno da dobije `name` nazad. +Kada pozovemo `CustomerID("Sukyoung")`, to je skraćena sintaksa za `CustomerID.apply("Sukyoung")`. +Kada pozovemo `case CustomerID(name) => customer1ID`, ustvari pozivamo `unapply` metodu. + +Metoda `unapply` se može koristiti i za dodjelu vrijednosti. + +```tut +val customer2ID = CustomerID("Nico") +val CustomerID(name) = customer2ID +println(name) // prints Nico +``` + +Ovo je ekvivalentno `val name = CustomerID.unapply(customer2ID).get`. Ako se uzorak ne podudari, baciće se `scala.MatchError` izuzetak: + +```tut:fail +val CustomerID(name2) = "--asdfasdfasdf" +``` + +Povratni tip od `unapply` se bira na sljedeći način: + +* Ako je samo test, vraća `Boolean`. Naprimjer `case even()` +* Ako vraća jednu pod-vrijednost tipa `T`, vraća `Option[T]` +* Ako vraća više pod-vrijednosti `T1,...,Tn`, grupiše ih u opcionu torku `Option[(T1,...,Tn)]`. + +Ponekad, broj pod-vrijednosti nije fiksan i želimo da vratimo listu. +Iz ovog razloga, također možete definisati uzorke pomoću `unapplySeq` koja vraća `Option[Seq[T]]`. +Ovaj mehanizam se koristi naprimjer za uzorak `case List(x1, ..., xn)`. diff --git a/_ba/tour/for-comprehensions.md b/_ba/tour/for-comprehensions.md new file mode 100644 index 0000000000..e425352643 --- /dev/null +++ b/_ba/tour/for-comprehensions.md @@ -0,0 +1,58 @@ +--- +layout: tour +title: For komprehensije +language: ba + +disqus: true + +partof: scala-tour + +num: 17 +next-page: generic-classes +previous-page: extractor-objects + +--- + +Scala ima skraćenu notaciju za pisanje *komprehensija sekvenci*. +Komprehensije imaju oblik +`for (enumeratori) yield e`, gdje su `enumeratori` lista enumeratora razdvojenih tačka-zarezima. +*Enumerator* je ili generator koji uvodi nove varijable, ili je filter. +Komprehensija evaluira tijelo `e` za svako vezivanje varijable generisano od strane enumeratora i vraća sekvencu ovih vrijednosti. + +Slijedi primjer: + +```tut +case class User(val name: String, val age: Int) + +val userBase = List(new User("Travis", 28), + new User("Kelly", 33), + new User("Jennifer", 44), + new User("Dennis", 23)) + +val twentySomethings = for (user <- userBase if (user.age >=20 && user.age < 30)) + yield user.name // i.e. add this to a list + +twentySomethings.foreach(name => println(name)) // prints Travis Dennis +``` +`for` petlja korištena s `yield`-om ustvari kreira `List`-u. Pošto smo rekli `yield user.name`, to je `List[String]`. `user <- userBase` je naš generator a `if (user.age >=20 && user.age < 30)` je čuvar koji filtrira korisnike koji su u svojim dvadesetim. + +Slijedi malo komplikovaniji primjer koji s dva generatora. Izračunava sve parove brojeva između `0` i `n-1` čija je suma jednaka vrijednosti `v`: + +```tut +def foo(n: Int, v: Int) = + for (i <- 0 until n; + j <- i until n if i + j == v) + yield (i, j) + +foo(10, 10) foreach { + case (i, j) => + print(s"($i, $j) ") // prints (1, 9) (2, 8) (3, 7) (4, 6) (5, 5) +} + +``` +Ovdje je `n == 10` i `v == 10`. U prvoj iteraciji, `i == 0` i `j == 0` tako da `i + j != v` i ništa se ne vraća. `j` se povećava 9 puta prije nego se `i` poveća na `1`. +Bez `if` čuvara, ovo bi ispisalo sljedeće: +``` + +(0, 0) (0, 1) (0, 2) (0, 3) (0, 4) (0, 5) (0, 6) (0, 7) (0, 8) (0, 9) (1, 1) ... +``` diff --git a/_ba/tour/generic-classes.md b/_ba/tour/generic-classes.md new file mode 100644 index 0000000000..b9601f024c --- /dev/null +++ b/_ba/tour/generic-classes.md @@ -0,0 +1,71 @@ +--- +layout: tour +title: Generičke klase +language: ba + +discourse: true + +partof: scala-tour + +num: 18 +next-page: variances +previous-page: for-comprehensions +assumed-knowledge: classes unified-types + +--- + +Generičke klase su klase koje primaju tipove kao parametre. +Vrlo su korisne za implementiranje kolekcija. + +## Definisanje generičke klase + +Generičke klase primaju tip kao parametar u uglastim zagradama `[]`. +Konvencija je da se koristi slovo `A` kao identifikator tipa, mada se može koristiti bilo koje ime. + +```tut +class Stack[A] { + private var elements: List[A] = Nil + def push(x: A) { elements = x :: elements } + def peek: A = elements.head + def pop(): A = { + val currentTop = peek + elements = elements.tail + currentTop + } +} +``` + +Ova implementacija `Stack` klase prima bilo koji tip `A` kao parametar. +Ovo znači da unutarnja lista, `var elements: List[A] = Nil`, može čuvati samo elemente tipa `A`. +Metoda `def push` prima samo objekte tipa `A` (napomena: `elements = x :: elements` dodjeljuje varijabli `elements` novu listu kreiranu dodavanjem `x` na trenutne `elements`). + +## Korištenje + +Da bi koristili generičku klasu, stavite tip u uglaste zagrade umjesto `A`. +``` +val stack = new Stack[Int] +stack.push(1) +stack.push(2) +println(stack.pop) // prints 2 +println(stack.pop) // prints 1 +``` +Instanca `stack` može čuvati samo Int-ove. Međutim, ako tipski argument ima podtipove, oni mogu biti proslijeđeni: +``` +class Fruit +class Apple extends Fruit +class Banana extends Fruit + +val stack = new Stack[Fruit] +val apple = new Apple +val banana = new Banana + +stack.push(apple) +stack.push(banana) +``` +Klasa `Apple` i `Banana` obje nasljeđuju `Fruit` tako da možemo stavljati instance `apple` i `banana` na stek za `Fruit`. + +_Napomena: nasljeđivanje generičkih tipova je *invarijantno*. +Ovo znači da ako imamo stek karaktera, koji ima tip `Stack[Char]` onda on ne može biti korišten kao stek cijelih brojeva tipa `Stack[Int]`. +Ovo bi bilo netačno (unsound) jer bi onda mogli stavljati i integere na stek karaktera. +Zaključimo, `Stack[A]` je podtip `Stack[B]` ako i samo ako je `A = B`. +Pošto ovo može biti prilično ograničavajuće, Scala ima i [anotacije tipskih parametara](variances.html) za kontrolisanje ponašanja podtipova generičkih tipova._ diff --git a/ba/tutorials/tour/_posts/2017-02-13-higher-order-functions.md b/_ba/tour/higher-order-functions.md similarity index 52% rename from ba/tutorials/tour/_posts/2017-02-13-higher-order-functions.md rename to _ba/tour/higher-order-functions.md index 0b60f239fe..50531716b0 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-higher-order-functions.md +++ b/_ba/tour/higher-order-functions.md @@ -1,39 +1,47 @@ --- -layout: tutorial +layout: tour title: Funkcije višeg reda +language: ba -disqus: true +discourse: true + +partof: scala-tour + +num: 8 +next-page: nested-functions +previous-page: mixin-class-composition -tutorial: scala-tour -categories: tour -num: 7 -outof: 33 -language: ba --- Scala dozvoljava definisanje funkcija višeg reda. To su funkcije koje _primaju druge funkcije kao parametre_, ili čiji je _rezultat funkcija_. Ovo je funkcija `apply` koja uzima drugu funkciju `f` i vrijednost `v` i primjenjuje funkciju `f` na `v`: - def apply(f: Int => String, v: Int) = f(v) +```tut +def apply(f: Int => String, v: Int) = f(v) +``` -_Napomena: metode se automatski pretvoraju u funkcije ako kontekst zahtijeva korištenje this._ +_Napomena: metode se automatski pretvaraju u funkcije ako to kontekst zahtijeva._ Ovo je još jedan primjer: - class Decorator(left: String, right: String) { - def layout[A](x: A) = left + x.toString() + right - } - - object FunTest extends App { - def apply(f: Int => String, v: Int) = f(v) - val decorator = new Decorator("[", "]") - println(apply(decorator.layout, 7)) - } +```tut +class Decorator(left: String, right: String) { + def layout[A](x: A) = left + x.toString() + right +} + +object FunTest extends App { + def apply(f: Int => String, v: Int) = f(v) + val decorator = new Decorator("[", "]") + println(apply(decorator.layout, 7)) +} +``` -Izvršenjem se dobije izlaz: +Izvršavanjem se dobije izlaz: - [7] +``` +[7] +``` U ovom primjeru, metoda `decorator.layout` je automatski pretvorena u vrijednost tipa `Int => String` koju zahtijeva metoda `apply`. Primijetite da je metoda `decorator.layout` _polimorfna metoda_ (tj. apstrahuje neke tipove u svom potpisu) diff --git a/ba/tutorials/tour/_posts/2017-02-13-implicit-conversions.md b/_ba/tour/implicit-conversions.md similarity index 59% rename from ba/tutorials/tour/_posts/2017-02-13-implicit-conversions.md rename to _ba/tour/implicit-conversions.md index eacc3b0741..69609f61f9 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-implicit-conversions.md +++ b/_ba/tour/implicit-conversions.md @@ -1,14 +1,16 @@ --- -layout: tutorial +layout: tour title: Implicitne konverzije +language: ba -disqus: true +discourse: true + +partof: scala-tour + +num: 27 +next-page: polymorphic-methods +previous-page: implicit-parameters -tutorial: scala-tour -categories: tour -num: 26 -outof: 33 -language: ba --- Implicitna konverzija iz tipa `S` u tip `T` je definisana kao implicitna vrijednost koja ima tip `S => T` (funkcija), @@ -24,25 +26,37 @@ U drugom slučaju, traži se konverzija `c` koja je primjenjiva na `e` i čiji r Sljedeća operacija nad dvije liste xs i ys tipa `List[Int]` je legalna: - xs <= ys +``` +xs <= ys +``` pod pretpostavkom da su implicitne metode `list2ordered` i `int2ordered` definisane i dostupne (in scope): - implicit def list2ordered[A](x: List[A]) - (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] = - new Ordered[List[A]] { /* .. */ } - - implicit def int2ordered(x: Int): Ordered[Int] = - new Ordered[Int] { /* .. */ } +``` +implicit def list2ordered[A](x: List[A]) + (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] = + new Ordered[List[A]] { /* .. */ } + +implicit def int2ordered(x: Int): Ordered[Int] = + new Ordered[Int] { /* .. */ } +``` Implicitno importovani objekt `scala.Predef` deklariše nekoliko predefinisanih tipova (npr. `Pair`) i metoda (npr. `assert`) ali i nekoliko implicitnih konverzija. Naprimjer, kada se pozivaju Javine metode koje očekuju `java.lang.Integer`, možete proslijediti `scala.Int`. Možete, zato što `Predef` uključuje slj. implicitnu konverziju: - implicit def int2Integer(x: Int) = - java.lang.Integer.valueOf(x) +```tut +import scala.language.implicitConversions + +implicit def int2Integer(x: Int) = + java.lang.Integer.valueOf(x) +``` + +Pošto su implicitne konverzije opasne ako se koriste pogrešno, kompajler upozorava kada kompajlira definiciju implicitne konverzije. + +Da biste ugasili ova upozorenja, uradite jedno od ovog: + +* Importujte `scala.language.implicitConversions` u domen definicije implicitne konverzije +* Upalite kompajler s `-language:implicitConversions` -Da bi definisali vlastite implicitne konverzije, morate importovati `scala.language.implicitConversions` -(ili uključiti kompajler s flegom `-language:implicitConversions`). -Ova osobina mora biti korištena eksplicitno jer ima potencijalne zamke ako se koristi neselektivno. diff --git a/_ba/tour/implicit-parameters.md b/_ba/tour/implicit-parameters.md new file mode 100644 index 0000000000..d3ebff2667 --- /dev/null +++ b/_ba/tour/implicit-parameters.md @@ -0,0 +1,71 @@ +--- +layout: tour +title: Implicitni parametri +language: ba + +discourse: true + +partof: scala-tour + +num: 26 +next-page: implicit-conversions +previous-page: self-types + +--- + +Metoda s _implicitnim parametrima_ može biti primijenjena na argumente kao i normalna metoda. +U ovom slučaju, implicitna labela nema nikakav efekt. +Međutim, ako takvoj metodi nedostaju argumenti za implicitne parametre, ti argumenti će biti proslijeđeni automatski. + +Argumenti koji se mogu proslijediti kao implicitni parametri spadaju u dvije kategorije: + +* Prva, kvalifikovani su svi identifikatori x koji su dostupni pri pozivu metode bez prefiksa i predstavljaju implicitnu definiciju ili implicitni parameter. +* Druga, kvalifikovani su također svi članovi prijateljskih objekata (modula) tipova implicitnih parametara. + +U sljedećem primjeru definisaćemo metodu `sum` koja izračunava sumu liste elemenata koristeći `add` i `unit` operacije monoida. +Molimo primijetite da implicitne vrijednosti ne mogu biti top-level, već moraju biti članovi templejta. + +```tut +abstract class SemiGroup[A] { + def add(x: A, y: A): A +} +abstract class Monoid[A] extends SemiGroup[A] { + def unit: A +} +object ImplicitTest extends App { + implicit object StringMonoid extends Monoid[String] { + def add(x: String, y: String): String = x concat y + def unit: String = "" + } + implicit object IntMonoid extends Monoid[Int] { + def add(x: Int, y: Int): Int = x + y + def unit: Int = 0 + } + def sum[A](xs: List[A])(implicit m: Monoid[A]): A = + if (xs.isEmpty) m.unit + else m.add(xs.head, sum(xs.tail)) + + println(sum(List(1, 2, 3))) // uses IntMonoid implicitly + println(sum(List("a", "b", "c"))) // uses StringMonoid implicitly +} +``` + +Ovaj primjer koristi strukturu iz apstraktne algebre da pokaže kako implicitni parametri rade. Polugrupa, modelovana s `SemiGroup` ovdje, je algebarska struktura na skupu `A` s (asocijativnom) operacijom, zvanom `add` ovdje, koja kombinuje par `A`-ova i vraća neki `A`. + +Monoid, modelovan s `Monoid` ovdje, je polugrupa s posebnim elementom `A`, zvanim `unit`, koji kada se kombinujes nekim drugim elementom `A` vraća taj drugi element. + +Da bismo pokazali kako implicitni parametri rade, prvo definišemo monoide `StringMonoid` i `IntMonoid` za stringove i integere, respektivno. +Ključna riječ `implicit` kaže da se dati objekat može koristiti implicitno, unutar ovog domena, kao parametar funkcije obilježene s implicit. + +Metoda `sum` prima `List[A]` i vraća `A`, koji predstavlja rezultat primjene operacije monoida sukcesivno kroz cijelu listu. Navodeći parametar `m` implicitnim ovdje znači da samo moramo proslijediti `xs` parametar pri pozivu, pošto imamo `List[A]` znamo šta je tip `A` ustvari i stoga tip `Monoid[A]` se traži. +Možemo implicitno naći bilo koji `val` ili `object` u trenutnom domenu koji ima taj tip i koristiti ga bez da ga navedemo eksplicitno. + +Napokon, zovemo `sum` dvaput, sa samo jednim parametrom svaki put. +Pošto je drugi parametar metode `sum`, `m`, implicitan, njegova vrijednost se traži u trenutnom domenu, bazirano na tipu monoida koji se traži, što znači da se oba izraza mogu izračunati potpuno. + +Ovo je izlaz navedenog Scala programa: + +``` +6 +abc +``` diff --git a/_ba/tour/inner-classes.md b/_ba/tour/inner-classes.md new file mode 100644 index 0000000000..0917237fe7 --- /dev/null +++ b/_ba/tour/inner-classes.md @@ -0,0 +1,96 @@ +--- +layout: tour +title: Unutarnje klase +language: ba + +discourse: true + +partof: scala-tour + +num: 22 +next-page: abstract-types +previous-page: lower-type-bounds + +--- + +U Scali je moguće da klase imaju druge klase kao članove. +Nasuprot jezicima sličnim Javi, gdje su unutarnje klase članovi vanjske klase, +u Scali takve unutarnje klase su vezane za vanjski objekt. +Pretpostavimo da želimo da nas kompejler spriječi da pomiješamo koji čvorovi pripadaju kojem grafu. Tipovi zavisni od putanje (en. path-dependent) omogućuju rješenje. + +Radi ilustracije razlike, prikazaćemo implementaciju klase grafa: + +```tut +class Graph { + class Node { + var connectedNodes: List[Node] = Nil + def connectTo(node: Node) { + if (connectedNodes.find(node.equals).isEmpty) { + connectedNodes = node :: connectedNodes + } + } + } + var nodes: List[Node] = Nil + def newNode: Node = { + val res = new Node + nodes = res :: nodes + res + } +} +``` + +U našem programu, grafovi su predstavljeni listom čvorova (`List[Node]`). +Svaki čvor ima listu drugih čvorova s kojima je povezan (`connectedNodes`). Klasa `Node` je _path-dependent tip_ jer je ugniježdena u klasi `Graph`. Stoga, svi čvorovi u `connectedNodes` moraju biti kreirani koristeći `newNode` iz iste instance klase `Graph`. + +```tut +val graph1: Graph = new Graph +val node1: graph1.Node = graph1.newNode +val node2: graph1.Node = graph1.newNode +val node3: graph1.Node = graph1.newNode +node1.connectTo(node2) +node3.connectTo(node1) +``` + +Eksplicitno smo deklarisali tip `node1`, `node2`, i `node3` kao `graph1.Node` zbog jasnosti ali ga je kompajler mogao sam zaključiti. Pošto kada pozivamo `graph1.newNode` koja poziva `new Node`, metoda koristi instancu `Node` specifičnu instanci `graph1`. + +Da imamo dva grafa, sistem tipova Scale ne dozvoljava miješanje čvorova definisanih u različitim grafovima, +jer čvorovi različitih grafova imaju različit tip. +Ovo je primjer netačnog programa: + +``` +val graph1: Graph = new Graph +val node1: graph1.Node = graph1.newNode +val node2: graph1.Node = graph1.newNode +node1.connectTo(node2) // legal +val graph2: Graph = new Graph +val node3: graph2.Node = graph2.newNode +node1.connectTo(node3) // illegal! +``` + +Tip `graph1.Node` je različit od `graph2.Node`. +U Javi bi zadnja linija prethodnog primjera bila tačna. +Za čvorove oba grafa, Java bi dodijelila isti tip `Graph.Node`; npr. `Node` bi imala prefiks klase `Graph`. +U Scali takav tip je također moguće izraziti, piše se kao `Graph#Node`. +Ako želimo povezati čvorove različitih grafova, moramo promijeniti definiciju naše inicijalne implementacije grafa: + +```tut +class Graph { + class Node { + var connectedNodes: List[Graph#Node] = Nil + def connectTo(node: Graph#Node) { + if (connectedNodes.find(node.equals).isEmpty) { + connectedNodes = node :: connectedNodes + } + } + } + var nodes: List[Node] = Nil + def newNode: Node = { + val res = new Node + nodes = res :: nodes + res + } +} +``` + +> Primijetite da ovaj program ne dozvoljava da dodamo čvor u dva različita grafa. +Ako bi htjeli ukloniti i ovo ograničenje, moramo promijeniti tipski parametar `nodes` u `Graph#Node`. diff --git a/ba/tutorials/tour/_posts/2017-02-13-local-type-inference.md b/_ba/tour/local-type-inference.md similarity index 63% rename from ba/tutorials/tour/_posts/2017-02-13-local-type-inference.md rename to _ba/tour/local-type-inference.md index 6f3c206d91..926c3a4feb 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-local-type-inference.md +++ b/_ba/tour/local-type-inference.md @@ -1,14 +1,16 @@ --- -layout: tutorial +layout: tour title: Lokalno zaključivanje tipova (type inference) +language: ba -disqus: true +discourse: true + +partof: scala-tour + +num: 29 +next-page: operators +previous-page: polymorphic-methods -tutorial: scala-tour -categories: tour -num: 28 -outof: 33 -language: ba --- Scala ima ugrađen mehanizam zaključivanja tipova koji dozvoljava programeru da izostavi određene anotacije tipova. Često nije potrebno specificirati tip varijable u Scali, @@ -17,18 +19,22 @@ Povratni tipovi metoda također mogu biti izostavljeni jer oni odgovaraju tipu t Slijedi jedan primjer: - object InferenceTest1 extends App { - val x = 1 + 2 * 3 // tip x-a je Int - val y = x.toString() // tip y-a je String - def succ(x: Int) = x + 1 // metoda succ vraća Int - } +```tut +object InferenceTest1 extends App { + val x = 1 + 2 * 3 // the type of x is Int + val y = x.toString() // the type of y is String + def succ(x: Int) = x + 1 // method succ returns Int values +} +``` Za rekurzivne metode, kompajler nije u mogućnosti da zaključi tip rezultata. Ovo je program koji se ne može kompajlirati iz ovog razloga: - object InferenceTest2 { - def fac(n: Int) = if (n == 0) 1 else n * fac(n - 1) - } +```tut:fail +object InferenceTest2 { + def fac(n: Int) = if (n == 0) 1 else n * fac(n - 1) +} +``` Također nije obavezno specificirati tipske parametre kada se pozivaju [polimorfne metode](polymorphic-methods.html) ili kada se [generičke klase](generic-classes.html) instanciraju. @@ -36,24 +42,31 @@ Scala kompajler će zaključiti nedostajuće tipske parametre iz konteksta i iz Ovo je primjer koji to ilustrira: - case class MyPair[A, B](x: A, y: B); - object InferenceTest3 extends App { - def id[T](x: T) = x - val p = MyPair(1, "scala") // tip: MyPair[Int, String] - val q = id(1) // tip: Int - } +``` +case class MyPair[A, B](x: A, y: B); +object InferenceTest3 extends App { + def id[T](x: T) = x + val p = MyPair(1, "scala") // type: MyPair[Int, String] + val q = id(1) // type: Int +} +``` + Zadnje dvije linije ovog programa su ekvivalentne sljedećem kodu gdje su svi zaključeni tipovi eksplicitno napisani: - val x: MyPair[Int, String] = MyPair[Int, String](1, "scala") - val y: Int = id[Int](1) +``` +val x: MyPair[Int, String] = MyPair[Int, String](1, "scala") +val y: Int = id[Int](1) +``` U nekim situacijama može biti vrlo opasno osloniti se na Scalin mehanizam zaključivanja tipova: - object InferenceTest4 { - var obj = null - obj = new Object() - } +```tut:fail +object InferenceTest4 { + var obj = null + obj = new Object() +} +``` Ovaj program se ne može kompajlirati jer je zaključeni tip varijable `obj` tip `Null`. Pošto je jedina vrijednost tog tipa `null`, nemoguće je dodijeliti ovoj varijabli neku drugu vrijednost. diff --git a/_ba/tour/lower-type-bounds.md b/_ba/tour/lower-type-bounds.md new file mode 100644 index 0000000000..09db59d94d --- /dev/null +++ b/_ba/tour/lower-type-bounds.md @@ -0,0 +1,76 @@ +--- +layout: tour +title: Donja granica tipa +language: ba + +discourse: true + +partof: scala-tour + +num: 21 +next-page: inner-classes +previous-page: upper-type-bounds +prerequisite-knowledge: upper-type-bounds, generics, variance + +--- + +Dok [gornja granica tipa](upper-type-bounds.html) limitira tip na podtip nekog drugog tipa, +*donja granica tipa* limitira tip da bude nadtip nekog drugog tipa. +Izraz `B >: A` izražava tipski parametar `B` ili apstraktni tip `B` koji je nadtip tipa `A`. U većini slučajeva, `A` je tipski parametar klase a `B` je tipski parametar metode. + +Kroz sljedeći primjer vidjećemo zašto je ovo korisno: + +```tut:fail +trait Node[+B] { + def prepend(elem: B): Unit +} + +case class ListNode[+B](h: B, t: Node[B]) extends Node[B] { + def prepend(elem: B) = ListNode[B](elem, this) + def head: B = h + def tail = t +} + +case class Nil[+B]() extends Node[B] { + def prepend(elem: B) = ListNode[B](elem, this) +} +``` + +Ovaj program implementira jednostruko povezanu listu. +`Nil` predstavlja prazan element (tj. prazna lista). `class ListNode` je čvor koji sadrži element tipa `B` (`head`) i referencu na ostatak liste (`tail`). Klasa `Node` i njeni podtipovi su kovarijantni jer imaju `+B`. + + +Nažalost, ovaj program se _ne može kompajlirati_ jer je parametar `elem` u `prepend` tipa `B`, kojeg smo deklarisali *ko*varijantnim. +Ovo ne radi jer su funkcije *kontra*varijantne u svojim tipovima parametara i *ko*varijantne u svom tipu rezultata. + +Da bismo popravili ovo, moramo zamijeniti varijansu tipskog parametra `elem` u `prepend`. +Ovo radimo uvođenjem novog tipskog parametra `U` koji ima `B` kao svoju donju granicu tipa. + +```tut +trait Node[+B] { + def prepend[U >: B](elem: U) +} + +case class ListNode[+B](h: B, t: Node[B]) extends Node[B] { + def prepend[U >: B](elem: U) = ListNode[U](elem, this) + def head: B = h + def tail = t +} + +case class Nil[+B]() extends Node[B] { + def prepend[U >: B](elem: U) = ListNode[U](elem, this) +} +``` + +Sada možemo uraditi sljedeće: +```tut +trait Bird +case class AfricanSwallow() extends Bird +case class EuropeanSwallow() extends Bird + + +val africanSwallowList= ListNode[AfricanSwallow](AfricanSwallow(), Nil()) +val birdList: Node[Bird] = africanSwallowList +birdList.prepend(new EuropeanSwallow) +``` +`Node[Bird]` može biti dodijeljena `africanSwallowList` ali onda prihvatiti `EuropeanSwallow`e. diff --git a/_ba/tour/mixin-class-composition.md b/_ba/tour/mixin-class-composition.md new file mode 100644 index 0000000000..7a1940bcc0 --- /dev/null +++ b/_ba/tour/mixin-class-composition.md @@ -0,0 +1,92 @@ +--- +layout: tour +title: Kompozicija mixin klasa +language: ba + +discourse: true + +partof: scala-tour + +num: 6 +next-page: higher-order-functions +previous-page: traits +prerequisite-knowledge: inheritance, traits, abstract-classes, unified-types + +--- + +Mixini su trejtovi koji se koriste za kompoziciju klase. + +```tut +abstract class A { + val message: String +} +class B extends A { + val message = "I'm an instance of class B" +} +trait C extends A { + def loudMessage = message.toUpperCase() +} +class D extends B with C + +val d = new D +d.message // I'm an instance of class B +d.loudMessage // I'M AN INSTANCE OF CLASS B +``` +Klasa `D` je nadklasa od `B` i mixina `C`. +Klase mogu imati samo jednu nadklasu alid mogu imati više mixina (koristeći ključne riječi `extends` i `with` respektivno). Mixini i nadklasa mogu imati isti nadtip. + +Pogledajmo sada zanimljiviji primjer počevši od apstraktne klase: + +```tut +abstract class AbsIterator { + type T + def hasNext: Boolean + def next(): T +} +``` + +Klasa ima apstraktni tip `T` i standardne metode iteratora. +Dalje, implementiraćemo konkretnu klasu (svi apstraktni članovi `T`, `hasNext`, i `next` imaju implementacije): + +```tut +class StringIterator(s: String) extends AbsIterator { + type T = Char + private var i = 0 + def hasNext = i < s.length + def next() = { + val ch = s charAt i + i += 1 + ch + } +} +``` + +`StringIterator` prima `String` i može se koristiti za iteraciju nad `String`om (npr. da vidimo da li sadrži određeni karakter). + + trait RichIterator extends AbsIterator { + def foreach(f: T => Unit) { while (hasNext) f(next()) } + } + +Kreirajmo sada trejt koji također nasljeđuje `AbsIterator`. + +```tut +trait RichIterator extends AbsIterator { + def foreach(f: T => Unit): Unit = while (hasNext) f(next()) +} +``` + +Pošto je `RichIterator` trejt, on ne mora implementirati apstraktne članove `AbsIterator`a. + +Željeli bismo iskombinirati funkcionalnosti `StringIterator`a i `RichIterator`a u jednoj klasi. + +```tut +object StringIteratorTest extends App { + class Iter extends StringIterator("Scala") with RichIterator + val iter = new Iter + iter foreach println +} +``` + +Nova klasa `Iter` ima `StringIterator` kao nadklasu i `RichIterator` kao mixin. + +S jednostrukim nasljeđivanjem ne bismo mogli postići ovaj nivo fleksibilnosti. diff --git a/_ba/tour/named-arguments.md b/_ba/tour/named-arguments.md new file mode 100644 index 0000000000..a2e98b1d56 --- /dev/null +++ b/_ba/tour/named-arguments.md @@ -0,0 +1,39 @@ +--- +layout: tour +title: Imenovani parametri +language: ba + +discourse: true + +partof: scala-tour + +num: 34 +previous-page: default-parameter-values +prerequisite-knowledge: function-syntax + +--- + +Kada se pozivaju metode, možete koristiti imena varijabli eksplicitno pri pozivu: + +```tut + def printName(first: String, last: String): Unit = { + println(first + " " + last) + } + + printName("John", "Smith") // Prints "John Smith" + printName(first = "John", last = "Smith") // Prints "John Smith" + printName(last = "Smith", first = "John") // Prints "John Smith" +``` + +Primijetite da kada koristite imenovane parametre pri pozivu, redoslijed nije bitan, dok god su svi parametri imenovani. +Neimenovani argumenti moraju doći prvi i u zadanom redoslijedu kao u potpisu metode. + +``` +def printName(first: String, last: String): Unit = { + println(first + " " + last) +} + +printName(last = "Smith", "john") // Does not compile +``` + +Imenovani parametri ne rade kada se pozivaju metode iz Jave. diff --git a/_ba/tour/nested-functions.md b/_ba/tour/nested-functions.md new file mode 100644 index 0000000000..58bb5765e2 --- /dev/null +++ b/_ba/tour/nested-functions.md @@ -0,0 +1,38 @@ +--- +layout: tour +title: Ugniježdene metode +language: ba + +discourse: true + +partof: scala-tour + +num: 9 +next-page: currying +previous-page: higher-order-functions + +--- + +U Scali je moguće ugnježdavati definicije metode. +Sljedeći objekt sadrži metodu `factorial` za računanje faktorijela datog broja: + +```tut + def factorial(x: Int): Int = { + def fact(x: Int, accumulator: Int): Int = { + if (x <= 1) accumulator + else fact(x - 1, x * accumulator) + } + fact(x, 1) + } + + println("Factorial of 2: " + factorial(2)) + println("Factorial of 3: " + factorial(3)) +``` + +Izlaz ovog programa je: + +``` +Factorial of 2: 2 +Factorial of 3: 6 +``` + diff --git a/_ba/tour/operators.md b/_ba/tour/operators.md new file mode 100644 index 0000000000..95d7d977e9 --- /dev/null +++ b/_ba/tour/operators.md @@ -0,0 +1,87 @@ +--- +layout: tour +title: Operatori +language: ba + +discourse: true + +partof: scala-tour + +num: 30 +next-page: by-name-parameters +previous-page: local-type-inference +prerequisite-knowledge: case-classes + +--- + +U Scali, operatori su metode. +Bilo koja metoda koja prima samo jedan parametar može biti korištena kao _infiksni operator_. Npr, `+` se može pozvati s tačka-notacijom: +``` +10.+(1) +``` + +Međutim, lakše je čitati kada se napiše kao infiksni operator: +``` +10 + 1 +``` + +## Definisanje i korištenje operatora +Možete koristiti bilo koji legalni identifikator kao operator. +To uključuje i imena kao `add` ili simbole kao `+`. +```tut +case class Vec(val x: Double, val y: Double) { + def +(that: Vec) = new Vec(this.x + that.x, this.y + that.y) +} + +val vector1 = Vec(1.0, 1.0) +val vector2 = Vec(2.0, 2.0) + +val vector3 = vector1 + vector2 +vector3.x // 3.0 +vector3.y // 3.0 +``` +Klasa `Vec` ima metodu `+` koja se može koristiti za sabiranje `vector1` i `vector2`. +Koristeći zagrade, možete pisati kompleksne izraze s čitljivom sintaksom. + +Slijedi definicija klase `MyBool` koja definiše tri metode `and`, `or`, i `negate`. + +```tut +case class MyBool(x: Boolean) { + def and(that: MyBool): MyBool = if (x) that else this + def or(that: MyBool): MyBool = if (x) this else that + def negate: MyBool = MyBool(!x) +} +``` + +Sada je moguće koristiti `and` i `or` kao infiksne operatore: + +```tut +def not(x: MyBool) = x.negate +def xor(x: MyBool, y: MyBool) = (x or y) and not(x and y) +``` + +Ovo pomaže da definicija `xor` metode bude čitljivija. + +## Prednost +Kada izraz koristi više operatora, operatori se primjenjuju bazirano na prioritetu prvog karaktera: +``` +(karakteri koji nisu jedan od ovih ispod) +* / % ++ - +: += ! +< > +& +^ +| +(sva slova) +``` +Ovo se odnosi na metode koje definišete. Npr, sljedeći izraz: +``` +a + b ^? c ?^ d less a ==> b | c +``` +je ekvivalentan +``` +((a + b) ^? (c ?^ d)) less ((a ==> b) | c) +``` +`?^` ima najveću prednost jer počinje s karakterom `?`. `+` ima drugu prednost, pa `^?`, `==>`, `|`, i `less`. diff --git a/_ba/tour/pattern-matching.md b/_ba/tour/pattern-matching.md new file mode 100644 index 0000000000..9e304a3fd0 --- /dev/null +++ b/_ba/tour/pattern-matching.md @@ -0,0 +1,161 @@ +--- +layout: tour +title: Podudaranje uzoraka (pattern matching) +language: ba + +discourse: true + +partof: scala-tour + +num: 12 + +next-page: singleton-objects +previous-page: case-classes +prerequisite-knowledge: case-classes, string-interpolation, subtyping + +--- + +Podudaranje uzoraka je mehanizam za provjeranje da li vrijednost odgovara uzroku. Uspješno podudaranje može također i dekonstruisati vrijednost na njene dijelove. Ono je moćnija verzija `switch` izjave u Javi tako da se može koristiti umjesto serije if/else izjava. + +## Sintaksa +Izraz za podudaranje ima vrijednost, `match` ključnu riječ, i bar jednu `case` klauzu. +```tut +import scala.util.Random + +val x: Int = Random.nextInt(10) + +x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "many" +} +``` +`val x` iznad je nasumično odabrani integer između 0 i 10. +`x` postaje lijevi operand `match` operatora a na desnoj strani je izraz s četiri slučaja. +Zadnji slučaj, `_`, je "uhvati sve" slučaj za brojeve veće od 2. +Slučajevi se još zovu i _alternative_. + +Izrazi za podudaranje imaju vrijednost. +```tut +def matchTest(x: Int): String = x match { + case 1 => "one" + case 2 => "two" + case _ => "many" +} +matchTest(3) // many +matchTest(1) // one +``` +Ovaj izraz za podudaranje ima tip `String` jer svi slučajevi vraćaju `String`. +Stoga, metoda `matchTest` vraća `String`. + +## Podudaranje case klasa + +Case klase su posebno korisne za podudaranje uzoraka. + +```tut +abstract class Notification + +case class Email(sender: String, title: String, body: String) extends Notification + +case class SMS(caller: String, message: String) extends Notification + +case class VoiceRecording(contactName: String, link: String) extends Notification + + +``` +`Notification` je apstraktna nadklasa koja ima tri konkretna tipa implementirana kao case klase `Email`, `SMS`, i `VoiceRecording`. +Sada možemo podudarati uzorke s ovim case klasama: + +``` +def showNotification(notification: Notification): String = { + notification match { + case Email(email, title, _) => + s"You got an email from $email with title: $title" + case SMS(number, message) => + s"You got an SMS from $number! Message: $message" + case VoiceRecording(name, link) => + s"you received a Voice Recording from $name! Click the link to hear it: $link" + } +} +val someSms = SMS("12345", "Are you there?") +val someVoiceRecording = VoiceRecording("Tom", "voicerecording.org/id/123") + +println(showNotification(someSms)) // prints You got an SMS from 12345! Message: Are you there? + +println(showNotification(someVoiceRecording)) // you received a Voice Recording from Tom! Click the link to hear it: voicerecording.org/id/123 +``` +Metoda `showNotification` prima parametar tipa `Notification` i podudara tip `Notification` (tj. traži da li je to `Email`, `SMS`, ili `VoiceRecording`). +U slučaju `case Email(email, title, _)` polja `email` i `title` se koriste za povratnu vrijednostali se `body` ignoriše s `_`. + +## Čuvari uzoraka (en. guards) +Čuvari uzoraka su jednostavno boolean izrazi koji se koriste za preciziranje uzorka. +Samo dodajte `if ` nakon uzorka. +``` + +def showImportantNotification(notification: Notification, importantPeopleInfo: Seq[String]): String = { + notification match { + case Email(email, _, _) if importantPeopleInfo.contains(email) => + "You got an email from special someone!" + case SMS(number, _) if importantPeopleInfo.contains(number) => + "You got an SMS from special someone!" + case other => + showNotification(other) // nothing special, delegate to our original showNotification function + } +} + +val importantPeopleInfo = Seq("867-5309", "jenny@gmail.com") + +val someSms = SMS("867-5309", "Are you there?") +val someVoiceRecording = VoiceRecording("Tom", "voicerecording.org/id/123") +val importantEmail = Email("jenny@gmail.com", "Drinks tonight?", "I'm free after 5!") +val importantSms = SMS("867-5309", "I'm here! Where are you?") + +println(showImportantNotification(someSms, importantPeopleInfo)) +println(showImportantNotification(someVoiceRecording, importantPeopleInfo)) +println(showImportantNotification(importantEmail, importantPeopleInfo)) +println(showImportantNotification(importantSms, importantPeopleInfo)) +``` + +U `case Email(email, _, _) if importantPeopleInfo.contains(email)`, uzorak se podudara samo ako je `email` u listi važnih ljudi. + +## Podudaranje samo tipa +Možete podudarati samo tip ovako: +```tut +abstract class Device +case class Phone(model: String) extends Device{ + def screenOff = "Turning screen off" +} +case class Computer(model: String) extends Device { + def screenSaverOn = "Turning screen saver on..." +} + +def goIdle(device: Device) = device match { + case p: Phone => p.screenOff + case c: Computer => c.screenSaverOn +} +``` +`def goIdle` ima različito ponašanje zavisno od tipa `Device`. +Ovo je korisno kada uzorak mora pozvati metodu na uzorku. +Konvencija je da se koristi prvo slovo tipa kao identifikator (`p` i `c` ovdje). + +## Zapečaćene klase (en. sealed) +Trejtovi i klase mogu biti `sealed` što znači da svi podtipovi moraju biti reklarisani u istom fajlu. +Ovo osigurava da su svi podtipovi poznati. + +```tut +sealed abstract class Furniture +case class Couch() extends Furniture +case class Chair() extends Furniture + +def findPlaceToSit(piece: Furniture): String = piece match { + case a: Couch => "Lie on the couch" + case b: Chair => "Sit on the chair" +} +``` +Ovo je korisno za podudaranje tipovajer nam ne treba "catch all" slučaj. + +## Napomene + +Scalin mehanizam podudaranja uzoraka je najkorisniji za algebarske tipove koji su izraženi kroz [case klase](case-classes.html). +Scala također dozvoljava definisanje uzoraka nezavisno od case klasa, koristeći `unapply` metode u [ekstraktor objektima](extractor-objects.html). diff --git a/_ba/tour/polymorphic-methods.md b/_ba/tour/polymorphic-methods.md new file mode 100644 index 0000000000..5765a5c127 --- /dev/null +++ b/_ba/tour/polymorphic-methods.md @@ -0,0 +1,38 @@ +--- +layout: tour +title: Polimorfne metode +language: ba + +discourse: true + +partof: scala-tour + +num: 28 + +next-page: local-type-inference +previous-page: implicit-conversions +prerequisite-knowledge: unified-types + +--- + +Metode u Scali mogu biti parametrizovane i s vrijednostima i s tipovima. +Sintaksa je slična kao kod generičkih klasa. +Vrijednosni parameteri ("obični") su ograđeni parom zagrada, dok su tipski parameteri deklarisani u paru uglatih zagrada. + +Slijedi primjer: + +```tut +def listOfDuplicates[A](x: A, length: Int): List[A] = { + if (length < 1) + Nil + else + x :: listOfDuplicates(x, length - 1) +} +println(listOfDuplicates[Int](3, 4)) // List(3, 3, 3, 3) +println(listOfDuplicates("La", 8)) // List(La, La, La, La, La, La, La, La) +``` + +Metoda `listOfDuplicates` je parametrizovana tipom `A` i vrijednostima parametara `x: A` i `n: Int`. +Ako je `length < 1` vraćamo praznu listu. U suprotnom dodajemo `x` na početak liste duplikata vraćene rekurzivnim pozivom `listOfDuplicates`. (napomena: `::` znači dodavanje elementa na početak sekvence). + +Kada pozovemo `listOfDuplicates` s `[Int]` kao tipskim parametrom, prvi argument mora biti `Int` a povratni tip će biti `List[Int]`. Međutim, ne morate uvijek eksplicitno navoditi tipski parametaryou jer kompajler često može zaključiti tip argumenta (`"La"` je String). Ustvari, ako se ova metoda poziva iz Jave, nemoguće je da se proslijedi tipski parametar. diff --git a/_ba/tour/regular-expression-patterns.md b/_ba/tour/regular-expression-patterns.md new file mode 100644 index 0000000000..bf6a256e76 --- /dev/null +++ b/_ba/tour/regular-expression-patterns.md @@ -0,0 +1,65 @@ +--- +layout: tour +title: Regularni izrazi +language: ba + +discourse: true + +partof: scala-tour + +num: 15 + +next-page: extractor-objects +previous-page: singleton-objects + +--- + +Regularni izrazi su stringovi koji se mogu koristiti za traženje uzoraka u podacima. +Bilo koji string se može pretvoriti u regularni izraz pozivom `.r` metode. + +```tut +import scala.util.matching.Regex + +val numberPattern: Regex = "[0-9]".r + +numberPattern.findFirstMatchIn("awesomepassword") match { + case Some(_) => println("Password OK") + case None => println("Password must contain a number") +} +``` + +U gornjem primjeru, `numberPattern` je `Regex` +(regularni izraz) kojim provjeravamo da li šifra sadrži broj. + +Također, možete tražiti grupe regularnih izraza koristeći zagrade. + +```tut +import scala.util.matching.Regex + +val keyValPattern: Regex = "([0-9a-zA-Z-#() ]+): ([0-9a-zA-Z-#() ]+)".r + +val input: String = + """background-color: #A03300; + |background-image: url(img/header100.png); + |background-position: top center; + |background-repeat: repeat-x; + |background-size: 2160px 108px; + |margin: 0; + |height: 108px; + |width: 100%;""".stripMargin + +for (patternMatch <- keyValPattern.findAllMatchIn(input)) + println(s"key: ${patternMatch.group(1)} value: ${patternMatch.group(2)}") +``` +Ovdje parsiramo ključeve i vrijednosti Stringa. +Svaki pogodak ima grupu pod-pogodaka. Ovo je izlaz: +``` +key: background-color value: #A03300 +key: background-image value: url(img +key: background-position value: top center +key: background-repeat value: repeat-x +key: background-size value: 2160px 108px +key: margin value: 0 +key: height value: 108px +key: width value: 100 +``` diff --git a/_ba/tour/self-types.md b/_ba/tour/self-types.md new file mode 100644 index 0000000000..0160d48250 --- /dev/null +++ b/_ba/tour/self-types.md @@ -0,0 +1,42 @@ +--- +layout: tour +title: Self-tipovi +language: ba + +discourse: true + +partof: scala-tour + +num: 25 +next-page: implicit-parameters +previous-page: compound-types +prerequisite-knowledge: nested-classes, mixin-class-composition + +--- +Self-tipovi su način da deklarišemo da trejt mora biti umiksan u drugi trejt, iako ga ne nasljeđuje direktno. +Ovo omogućuje da članovi zavisnog trejta budu dostupni bez importovanja. + +Self-tip je način da se suzi tip `this` ili drugi identifikator koji je alijas za `this`. +Sintaksa izgleda kao obična funkcija ali znači nešto sasvim drugačije. + +Da bi koristili self-tip u trejtu, napišite identifikator, tip drugog trejta za umiksavanje, i `=>` (tj. `someIdentifier: SomeOtherTrait =>`). +```tut +trait User { + def username: String +} + +trait Tweeter { + this: User => // reassign this + def tweet(tweetText: String) = println(s"$username: $tweetText") +} + +class VerifiedTweeter(val username_ : String) extends Tweeter with User { // We mixin User because Tweeter required it + def username = s"real $username_" +} + +val realBeyoncé = new VerifiedTweeter("Beyoncé") +realBeyoncé.tweet("Just spilled my glass of lemonade") // prints "real Beyoncé: Just spilled my glass of lemonade" +``` + +Pošto smo rekli `this: User =>` u `trait Tweeter`, sada je varijabla `username` u domenu korištenja `tweet` metode. +Ovo znači da pošto `VerifiedTweeter` nasljeđuje `Tweeter`, također mora umiksati i `User`a (koristeći `with User`). diff --git a/ba/tutorials/tour/_posts/2017-02-13-singleton-objects.md b/_ba/tour/singleton-objects.md similarity index 82% rename from ba/tutorials/tour/_posts/2017-02-13-singleton-objects.md rename to _ba/tour/singleton-objects.md index f8d86cdbee..0b570b4593 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-singleton-objects.md +++ b/_ba/tour/singleton-objects.md @@ -1,25 +1,29 @@ --- -layout: tutorial +layout: tour title: Singlton objekti +language: ba -disqus: true +discourse: true -tutorial: scala-tour -categories: tour -num: 12 +partof: scala-tour + +num: 13 + +next-page: regular-expression-patterns +previous-page: pattern-matching -outof: 33 -language: ba --- Metode i vrijednosti koje ne pripadaju individualnim instancama [klase](classes.html) pripadaju *singlton objektima*, označenim ključnom riječju `object` umjesto `class`. - package test +``` +package test - object Blah { - def sum(l: List[Int]): Int = l.sum - } +object Blah { + def sum(l: List[Int]): Int = l.sum +} +``` Metoda `sum` je dostupna globalno, i može se pozvati, ili importovati, kao `test.Blah.sum`. @@ -38,19 +42,21 @@ Većina singlton objekata nisu samostalni, već su povezani s istoimenom klasom. “Singlton objekt istog imena” case klase, pomenut ranije, je jedan primjer ovoga. U ovom slučaju, singlton objekt se zove *kompanjon objekt* klase, a klasa se zove *kompanjon klasa* objekta. -[Scaladoc](https://wiki.scala-lang.org/display/SW/Introduction) ima posebnu podršku za prebacivanje između klase i njenog kompanjona: +[Scaladoc](/style/scaladoc.html) ima posebnu podršku za prebacivanje između klase i njenog kompanjona: ako krug s velikim “C” ili “O” ima savijenu ivicu (kao papir), možete kliknuti na krug da pređete na kompanjon. Klasa i njen kompanjon objekt, ako ga ima, moraju biti definisani u istom izvornom fajlu: - class IntPair(val x: Int, val y: Int) +```tut +class IntPair(val x: Int, val y: Int) - object IntPair { - import math.Ordering +object IntPair { + import math.Ordering - implicit def ipord: Ordering[IntPair] = - Ordering.by(ip => (ip.x, ip.y)) - } + implicit def ipord: Ordering[IntPair] = + Ordering.by(ip => (ip.x, ip.y)) +} +``` Često vidimo typeclass (jedan od dizajn paterna) instance kao [implicitne vrijednosti](implicit-parameters.html), kao navedeni `ipord`, definisane u kompanjonu. @@ -65,15 +71,17 @@ Pristupa im se istom sintaksom, importovanim posebno ili grupno. Java programeri nekada definišu statičke članove privatnim kao pomoćne vrijednosti/funkcije. Iz ovoga proizilazi čest šablon kojim se importuju svi članovi kompanjon objekta u klasu: - class X { - import X._ +``` +class X { + import X._ - def blah = foo - } + def blah = foo +} - object X { - private def foo = 42 - } +object X { + private def foo = 42 +} +``` U kontekstu ključne riječi `private`, klasa i njen kompanjon su prijatelji. `object X` može pristupiti privatnim članovima od `class X`, i obrnuto. diff --git a/ba/tutorials/tour/_posts/2017-02-13-tour-of-scala.md b/_ba/tour/tour-of-scala.md similarity index 90% rename from ba/tutorials/tour/_posts/2017-02-13-tour-of-scala.md rename to _ba/tour/tour-of-scala.md index 87e0d9d37d..3e7505955b 100644 --- a/ba/tutorials/tour/_posts/2017-02-13-tour-of-scala.md +++ b/_ba/tour/tour-of-scala.md @@ -1,14 +1,16 @@ --- -layout: tutorial +layout: tour title: Uvod +language: ba + +discourse: true -disqus: true +partof: scala-tour -tutorial: scala-tour -categories: tour num: 1 -outof: 33 -language: ba + +next-page: basics + --- Scala je moderan programski jezik koji spaja više paradigmi, @@ -58,15 +60,12 @@ i za tipski bezbjedno proširenje softvera. U praksi, razvijanje domenski specifičnih aplikacija često zahtijeva i domenski specifične ekstenzije jezika. Scala omogućuje jedinstvenu kombinaciju mehanizama jezika koji olakšavaju elegantno dodavanje novih -jezičkih konstrukcija u formi biblioteka: - -* bilo koja metoda se može koristiti kao [infiksni ili postfiksni operator](operators.html) -* [closure se prave automatski zavisno od očekivanog tipa](automatic-closures.html) (ciljno tipiziranje). +jezičkih konstrukcija u formi biblioteka. Zajedničkom upotrebom obje mogućnosti olakšava definisanje novih izraza bez proširenja sintakse samog Scala jezika i bez korištenja olakšica u vidu macro-a ili meta-programiranja. -Scala je dizajnirana za interoperabilnost s popularnim Java 2 Runtime Environment (JRE). +Scala je dizajnirana za interoperabilnost s popularnim Java Runtime Environment (JRE). Konkretno, interakcija s popularnim objektno orijentisanim Java programskim jezikom je prirodna. Novije mogućnosti Jave kao [anotacije](annotations.html) i Javini generički tipovi imaju direktnu analogiju u Scali. Scaline mogućnosti bez analogija u Javi, kao što su [podrazumijevani](default-parameter-values.html) i [imenovani parametri](named-parameters.html), diff --git a/_ba/tour/traits.md b/_ba/tour/traits.md new file mode 100644 index 0000000000..d4ac8596e0 --- /dev/null +++ b/_ba/tour/traits.md @@ -0,0 +1,87 @@ +--- +layout: tour +title: Trejtovi +language: ba + +discourse: true + +partof: scala-tour + +num: 5 +next-page: mixin-class-composition +previous-page: classes +assumed-knowledge: expressions, classes, generics, objects, companion-objects + +--- + +Trejtovi se koriste za dijeljenje interfejsa i polja među klasama. +Slični su interfejsima Jave 8. +Klase i objekti mogu naslijediti trejtove ali trejtovi ne mogu biti instancirani i zato nemaju parametara. + +## Definisanje trejta +Minimalni trejt je samo ključna riječ `trait` i identifikator: + +```tut +trait HairColor +``` + +Trejtovi su vrlo korisni s generičkim tipovima i apstraktnim metodama. +```tut +trait Iterator[A] { + def hasNext: Boolean + def next(): A +} +``` + +Nasljeđivanje `trait Iterator[A]` traži tip `A` i implementacije metoda `hasNext` i `next`. + +## Korištenje trejtova +Koristite `extends` za nasljeđivanje trejta. Zatim implementirajte njegove apstraktne članove koristeći `override` ključnu riječ: +```tut +trait Iterator[A] { + def hasNext: Boolean + def next(): A +} + +class IntIterator(to: Int) extends Iterator[Int] { + private var current = 0 + override def hasNext: Boolean = current < to + override def next(): Int = { + if (hasNext) { + val t = current + current += 1 + t + } else 0 + } +} + + +val iterator = new IntIterator(10) +iterator.next() // prints 0 +iterator.next() // prints 1 +``` +Klasa `IntIterator` uzima parametar `to` kao gornju granicu. +Ona nasljeđuje `Iterator[Int]` što znači da `next` mora vraćati `Int`. + +## Podtipovi +Podtipovi trejtova mogu se koristiti gdje se trejt traži. +```tut +import scala.collection.mutable.ArrayBuffer + +trait Pet { + val name: String +} + +class Cat(val name: String) extends Pet +class Dog(val name: String) extends Pet + +val dog = new Dog("Harry") +val cat = new Cat("Sally") + +val animals = ArrayBuffer.empty[Pet] +animals.append(dog) +animals.append(cat) +animals.foreach(pet => println(pet.name)) // Prints Harry Sally +``` +`trait Pet` ima apstraktno polje `name` koje implementiraju `Cat` i `Dog` u svojim konstruktorima. +Na zadnjoj liniji, zovemo `pet.name` koje mora biti implementirano u bilo kom podtipu trejta `Pet`. diff --git a/_ba/tour/unified-types.md b/_ba/tour/unified-types.md new file mode 100644 index 0000000000..44af9e748e --- /dev/null +++ b/_ba/tour/unified-types.md @@ -0,0 +1,95 @@ +--- +layout: tour +title: Sjedinjeni tipovi +language: ba + +discourse: true + +partof: scala-tour + +num: 3 +next-page: classes +previous-page: basics +prerequisite-knowledge: classes, basics + +--- + +Sve vrijednosti u Scali su objekti, uključujući brojeve i funkcije. +Dijagram ispod prikazuje hijerarhiju Scala klasa. + +Scala Type Hierarchy + +## Hijerarhija tipova u Scali ## + +[`Any`](http://www.scala-lang.org/api/2.12.1/scala/Any.html) je nadtip svih tipova, zove se još i vrh-tip. +Definiše određene univerzalne metode kao što su `equals`, `hashCode` i `toString`. +`Any` ima dvije direktne podklase, `AnyVal` i `AnyRef`. + + +`AnyVal` predstavlja vrijednosne tipove. Postoji devet predefinisanih vrijednosnih tipova i oni ne mogu biti `null`: +`Double`, `Float`, `Long`, `Int`, `Short`, `Byte`, `Char`, `Unit` i `Boolean`. +`Unit` je vrijednosni tip koji ne nosi značajnu informaciju. Postoji tačno jedna instanca tipa `Unit` koja se piše `()`. +Sve funkcije moraju vratiti nešto tako da je `Unit` ponekad koristan povratni tip. + +`AnyRef` predstavlja referencne tipove. Svi nevrijednosni tipovi definišu se kao referencni. +Svaki korisnički definisan tip je podtip `AnyRef`. +Ako se Scala koristi u kontekstu JRE, onda `AnyRef` odgovara klasi `java.lang.Object`. + +Slijedi primjer koji demonstrira da su stringovi, integeri, karakteri, booleani i funkcije svi objekti kao bilo koji drugi: + +```tut +val list: List[Any] = List( + "a string", + 732, // an integer + 'c', // a character + true, // a boolean value + () => "an anonymous function returning a string" +) + +list.foreach(element => println(element)) +``` + +Definisana je varijabla `list` tipa `List[Any]`. Lista je inicijalizovana elementima različitih tipova, ali su svi instanca `Any`, tako da se mogu dodati u listu. + +Ovo je izlaz programa: + +``` +a string +732 +c +true + +``` + +## Kastovanje tipova +Vrijednosni tipovi mogu biti kastovani na sljedeći način: +Scala Type Hierarchy + +Npr: + +```tut +val x: Long = 987654321 +val y: Float = x // 9.8765434E8 (određena doza preciznosti se gubi ovdje) + +val face: Char = '☺' +val number: Int = face // 9786 +``` + +Kastovanje je jednosmjerno. Ovo se ne kompajlira: + +``` +val x: Long = 987654321 +val y: Float = x // 9.8765434E8 +val z: Long = y // Does not conform +``` + +Također možete kastovati i referencni tip u podtip. Ovo će biti pokriveno kasnije. + +## Nothing i Null +`Nothing` je podtip svih tipova, također se zove i donji tip (en. bottom type). Ne postoji vrijednost koja ima tip `Nothing`. +Česta upotreba ovog tipa je signalizacija neterminacije kao što je bacanje izuzetka, izlaz iz programa, ili beskonačna petlja (tj. tip izraza koji se ne izračunava u vrijednost, ili metoda koja se ne završava normalno). + +`Null` je podtip svih referencnih tipova (tj. bilo kog podtipa `AnyRef`). +Ima jednu vrijednost koja se piše literalom `null`. +`Null` se uglavnom koristi radi interoperabilnosti s ostalim JVM jezicima i skoro nikad se ne koristi u Scala kodu. +Alternative za `null` obradićemo kasnije. diff --git a/_ba/tour/upper-type-bounds.md b/_ba/tour/upper-type-bounds.md new file mode 100644 index 0000000000..b25b6347b3 --- /dev/null +++ b/_ba/tour/upper-type-bounds.md @@ -0,0 +1,55 @@ +--- +layout: tour +title: Gornja granica tipa +language: ba + +discourse: true + +partof: scala-tour +categories: tour +num: 20 +next-page: lower-type-bounds +previous-page: variances + +--- + +U Scali, [tipski parametri](generic-classes.html) i [apstraktni tipovi](abstract-types.html) mogu biti ograničeni granicom tipa. +Takve granice tipa ograničavaju konkretne vrijednosti tipskih varijabli i ponekad otkrivaju još informacija o članovima takvih tipova. + _Gornja granica tipa_ `T <: A` kaže da se tipska varijabla `T` odnosi na podtip tipa `A`. +Slijedi primjer koji demonstrira gornju granicu tipa za tipski parametar klase `PetContainer`: + +```tut +abstract class Animal { + def name: String +} + +abstract class Pet extends Animal {} + +class Cat extends Pet { + override def name: String = "Cat" +} + +class Dog extends Pet { + override def name: String = "Dog" +} + +class Lion extends Animal { + override def name: String = "Lion" +} + +class PetContainer[P <: Pet](p: P) { + def pet: P = p +} + +val dogContainer = new PetContainer[Dog](new Dog) +val catContainer = new PetContainer[Cat](new Cat) +// val lionContainer = new PetContainer[Lion](new Lion) +// ^this would not compile +``` +Klasa `PetContainer` prima tipski parametar `P` koji mora biti podtip od `Pet`. +`Dog` i `Cat` su podtipovi `Pet` tako da možemo kreirati novi `PetContainer[Dog]` i `PetContainer[Cat]`. +Međutim, ako pokušamo kreirati `PetContainer[Lion]`, dobićemo sljedeću grešku: + +`type arguments [Lion] do not conform to class PetContainer's type parameter bounds [P <: Pet]` + +To je zato što `Lion` nije podtip `Pet`. diff --git a/_ba/tour/variances.md b/_ba/tour/variances.md new file mode 100644 index 0000000000..a1f955543a --- /dev/null +++ b/_ba/tour/variances.md @@ -0,0 +1,183 @@ +--- +layout: tour +title: Varijanse +language: ba + +discourse: true + +partof: scala-tour + +num: 19 +next-page: upper-type-bounds +previous-page: generic-classes + +--- + +Varijansa je korelacija podtipskih veza kompleksnih tipova i podtipskih veza njihovih tipova komponenti. +Scala podržava anotacije varijanse tipskih parametara [generičkih klasa](generic-classes.html), dozvoljavajući im da budu kovarijantni, kontravarijantni, ili invarijantni ako se anotacije ne koriste. +Korištenje varijanse u sistemu tipova dozvoljava pravljenje intuitivnijih veza među kompleksnim tipovima, a nedostatak varijanse može ograničiti ponovno iskorištenje klasne apstrakcije. + +```tut +class Foo[+A] // kovarijantna klasa +class Bar[-A] // kontravarijantna klasa +class Baz[A] // invarijantna klasa +``` + +### Kovarijansa + +Tipski parametar `A` generičke klase može se učiniti kovarijantnim koristeći anotaciju `+A`. +Za neku klasu `List[+A]`, praveći `A` kovarijantnim implicira da za dva tipa `A` i `B` gdje je `A` podtip od `B`, onda je `List[A]` podtip od `List[B]`. +Ovo dozvoljava pravljenje vrlo intuitivnih podtipskih veza koristeći generiku. + +Razmotrite sljedeću strukturu klasa: + +```tut +abstract class Animal { + def name: String +} +case class Cat(name: String) extends Animal +case class Dog(name: String) extends Animal +``` + +Oboje `Cat` i `Dog` su podtipovi od `Animal`. +Scalina standardna biblioteka sadrži generičk nepromjenjivu `sealed abstract class List[+A]` klasu, gdje je tipski parametar `A` kovarijantan. +Ovo znači da je `List[Cat]` također i `List[Animal]`, a `List[Dog]` je isto `List[Animal]`. +Intuitivno, ima smisla da su lista mačaka i lista pasa također liste životinja, i trebalo bi da možete zamijeniti bilo koju od njih za `List[Animal]`. + +U sljedećem primjeru, metoda `printAnimalNames` prima listu životinja kao argument i ispisuje njihova imena, svako na idućoj liniji. +Da `List[A]` nije kovarijantna, zadnja dva poziva metode se ne bi kompajlirali, što bi značajno ograničilo korisnost `printAnimalNames` metode. + +```tut +object CovarianceTest extends App { + def printAnimalNames(animals: List[Animal]): Unit = { + animals.foreach { animal => + println(animal.name) + } + } + + val cats: List[Cat] = List(Cat("Whiskers"), Cat("Tom")) + val dogs: List[Dog] = List(Dog("Fido"), Dog("Rex")) + + printAnimalNames(cats) + // Whiskers + // Tom + + printAnimalNames(dogs) + // Fido + // Rex +} +``` + +### Kontravarijansa + +Tipski parametar `A` generičke klase može se učiniti kontravarijantnim koristeći anotaciju `-A`. +Ovo kreira podtipsku vezu između klase i njenih tipskih parametara koja je suprotna od kovarijanse. +To jest, za neku `class Writer[-A]`, kontravarijantno `A` znači da za dva tipa `A` i `B` gdje je `A` podtip `B`, `Writer[B]` je podtip `Writer[A]`. + +Razmotrimo `Cat`, `Dog`, i `Animal` klase u sljedećem primjeru: + +```tut +abstract class Printer[-A] { + def print(value: A): Unit +} +``` + +`Printer[A]` je jednostavna klasa koja zna ispisati neki tip `A`. Definišimo neke podklase za specifične tipove: + +```tut +class AnimalPrinter extends Printer[Animal] { + def print(animal: Animal): Unit = + println("The animal's name is: " + animal.name) +} + +class CatPrinter extends Printer[Cat] { + def print(cat: Cat): Unit = + println("The cat's name is: " + cat.name) +} +``` + +Ako `Printer[Cat]` zna kako da ispiše bilo koju `Cat`, a `Printer[Animal]` zna kako da ispiše bilo koju `Animal`, +ima smisla da `Printer[Animal]` također zna ispisati `Cat`. +Inverzna veza ne vrijedi, jer `Printer[Cat]` ne zna kako da ispiše bilo koju `Animal`. +Stoga, terbali bismo moći zamijeniti `Printer[Animal]` za `Printer[Cat]`, ako želimo, i praveći `Printer[A]` kontravarijantnim nam to dozvoljava. + + +```tut +object ContravarianceTest extends App { + val myCat: Cat = Cat("Boots") + + def printMyCat(printer: Printer[Cat]): Unit = { + printer.print(myCat) + } + + val catPrinter: Printer[Cat] = new CatPrinter + val animalPrinter: Printer[Animal] = new AnimalPrinter + + printMyCat(catPrinter) + printMyCat(animalPrinter) +} +``` + +Izlaz programa biće: + +``` +The cat's name is: Boots +The animal's name is: Boots +``` + +### Invarijansa + +Generičke klase u Scali su invarijantne po defaultu. +Ovo znač da nisu ni kovarijantne ni kontravarijantne. +U kontekstu sljedećeg primjera, `Container` klasa je invarijantna. +`Container[Cat]` _nije_ `Container[Animal]`, niti obrnuto. + +```tut +class Container[A](value: A) { + private var _value: A = value + def getValue: A = _value + def setValue(value: A): Unit = { + _value = value + } +} +``` + +Čini se prirodnim da bi `Container[Cat]` trebao biti također `Container[Animal]`, ali dozvoljavanjem promjenjivoj generičkoj klasi da bude kovarijantna ne bi bilo sigurno. +U ovom primjeru, vrlo važno je da je `Container` invarijantan. +Pretpostavimo da je `Container` kovarijantan, nešto slično bi se moglo desiti: + +``` +val catContainer: Container[Cat] = new Container(Cat("Felix")) +val animalContainer: Container[Animal] = catContainer +animalContainer.setValue(Dog("Spot")) +val cat: Cat = catContainer.getValue // Ups, završili smo dodjeljivanjem Dog u Cat +``` + +Srećom, kompajler nas sprečava davno prije nego dođemo do ovoga. + +### Drugi primjeri + +Još jedan primjer koji može pomoći za shvatanje varijanse je `trait Function1[-T, +R]` iz Scaline standardne biblioteke. +`Function1` predstavlja funkciju s jednim argumentom, gdje prvi tipski parametar `T` predstavlja tip argument, +a drugi parametar `R` predstavlja povratni tip. +`Function1` je kontravarijantna u tipu argumenta, i kovarijantna u povratnom tipu. +Za ovaj primjer koristićemo literal notaciju `A => B` za predstavljanje `Function1[A, B]`. + +Pretpostavimo da imamo sličnu hijerarhiju klasa `Cat`, `Dog`, `Animal` otprije, plus sljedeće: + +```tut +class SmallAnimal +class Mouse extends SmallAnimal +``` + +Recimo da radimo sa funkcijama koje primaju tipove životinja, i vraćaju tipove hrane koju jedu. +Ako bismo htjeli funkciju `Cat => SmallAnimal` (jer mačke jedu male životinje), ali nam je data `Animal => Mouse` funkcija, +naš program će i dalje raditi. +Intuitivno `Animal => Mouse` će i dalje prihvatiti `Cat` kao argument, jer `Cat` jeste `Animal`, i vraća `Mouse`, koji je također `SmallAnimal`. +Pošto sigurno i nevidljivo možemo zamijeniti prvo drugim, možemo reći da je `Animal => Mouse` podtip `Cat => SmallAnimal`. + +### Uporedba s drugim jezicima + +Varijansa je podržana na različite načine u nekim drugim jezicima sličnim Scali. +Npr, anotacije varijanse u Scali podsjećaju na one u C#, gdje se anotacije dodaju pri deklaraciji klasne apstrakcije (varijansa na strani deklaracije). +U Javi, međutim, anotacije varijanse daju korisnici kada se klasna apstrakcija koristi (varijansa na strani korisnika). diff --git a/_books/1-programming-in-scala-3rd.md b/_books/1-programming-in-scala-3rd.md new file mode 100644 index 0000000000..4c04d132c8 --- /dev/null +++ b/_books/1-programming-in-scala-3rd.md @@ -0,0 +1,12 @@ +--- +title: "Programming in Scala, 3rd ed" +link: http://booksites.artima.com/programming_in_scala_3ed +image: /resources/img/books/ProgrammingInScala.gif +status: Updated for Scala 2.12 +authors: ["Martin Odersky", "Lex Spoon", "Bill Benners"] +publisher: +--- + +(First edition [available for free online reading](http://www.artima.com/pins1ed/)) + +Being co-written by the language's designer, Martin Odersky, you will find it provides additional depth and clarity to the diverse features of the language. The book provides both an authoritative reference for Scala and a systematic tutorial covering all the features in the language. Once you are familiar with the basics of Scala you will appreciate having this source of invaluable examples and precise explanations of Scala on hand. The book is available from [Artima](http://booksites.artima.com/programming_in_scala_3ed). Award winning book - [Jolt Productivity award](http://www.drdobbs.com/joltawards/232601431) for Technical Books. diff --git a/_books/2-scala-for-the-impatient.md b/_books/2-scala-for-the-impatient.md new file mode 100644 index 0000000000..1113269218 --- /dev/null +++ b/_books/2-scala-for-the-impatient.md @@ -0,0 +1,22 @@ +--- +title: "Scala for the Impatient" +link: http://www.horstmann.com/scala/index.html +image: /resources/img/books/scala_for_the_impatient.png +status: Available Now +authors: ["Cay S. Horstmann"] +publisher: Addison-Wesley +publisherLink: https://heuk.pearson.com/about-us.html/Addison-Wesley/ +--- + +What you get: + +* A rapid introduction to Scala for programmers who are competent in Java, C#, or C++ +* Blog-length chunks of information that you can digest quickly +* An organization that you'll find useful as a quick reference + +What you don't get: + +* An introduction into programming or object-oriented design +* Religion about the superiority of one paradigm or another +* Cute or academic examples +* Mind-numbing details about syntax minutiae diff --git a/_books/3-programming-scala.md b/_books/3-programming-scala.md new file mode 100644 index 0000000000..eb814ff1fb --- /dev/null +++ b/_books/3-programming-scala.md @@ -0,0 +1,11 @@ +--- +title: "Programming Scala" +link: http://shop.oreilly.com/product/0636920033073.do +image: /resources/img/books/ProgrammingScala-final-border.gif +status: Updated for Scala 2.11 +authors: ["Alex Payne", "Dean Wampler"] +publisher: O’Reilly +publisherLink: http://www.oreilly.com/ +--- + +Both are industry experts, Alex Payne being the lead API programmer at Twitter, a social networking service based on Scala. O’Reilly, the publisher, writes: "Learn how to be more productive with Scala, a new multi-paradigm language for the Java Virtual Machine (JVM) that integrates features of both object-oriented and functional programming. With this book, you'll discover why Scala is ideal for highly scalable, component-based applications that support concurrency and distribution. You'll also learn how to leverage the wealth of Java class libraries to meet the practical needs of enterprise and Internet projects more easily." \ No newline at end of file diff --git a/_books/4-functional-programming-in-scala.md b/_books/4-functional-programming-in-scala.md new file mode 100644 index 0000000000..9a27404679 --- /dev/null +++ b/_books/4-functional-programming-in-scala.md @@ -0,0 +1,11 @@ +--- +title: "Functional Programming in Scala" +link: https://www.manning.com/books/functional-programming-in-scala +image: /resources/img/books/FPiS_93x116.png +status: Available now +authors: ["Paul Chiusano", "Rúnar Bjarnason"] +publisher: Manning +publisherLink: http://www.manning.com/ +--- + +"Functional programming (FP) is a style of software development emphasizing functions that don't depend on program state... Functional Programming in Scala is a serious tutorial for programmers looking to learn FP and apply it to the everyday business of coding. The book guides readers from basic techniques to advanced topics in a logical, concise, and clear progression. In it, you'll find concrete examples and exercises that open up the world of functional programming." \ No newline at end of file diff --git a/_books/5-scala-in-depth.md b/_books/5-scala-in-depth.md new file mode 100644 index 0000000000..6262e3a4ee --- /dev/null +++ b/_books/5-scala-in-depth.md @@ -0,0 +1,11 @@ +--- +title: "Scala in Depth" +link: http://www.manning.com/suereth +image: /resources/img/books/icon_Scala_in_Depth_93x116.png +status: Available now +authors: ["Joshua D. Suereth"] +publisher: Manning +publisherLink: http://www.manning.com/ +--- + +"While information about the Scala language is abundant, skilled practitioners, great examples, and insight into the best practices of the community are harder to find. Scala in Depth bridges that gap, preparing you to adopt Scala successfully for real world projects. Scala in Depth is a unique new book designed to help you integrate Scala effectively into your development process. By presenting the emerging best practices and designs from the Scala community, it guides you though dozens of powerful techniques example by example. There's no heavy-handed theory here-just lots of crisp, practical guides for coding in Scala." \ No newline at end of file diff --git a/_books/6-scala-puzzlers.md b/_books/6-scala-puzzlers.md new file mode 100644 index 0000000000..13b54f555e --- /dev/null +++ b/_books/6-scala-puzzlers.md @@ -0,0 +1,11 @@ +--- +title: "Scala Puzzlers" +link: http://www.artima.com/shop/scala_puzzlers +image: /resources/img/books/scala-puzzlers-book.jpg +status: Available now +authors: ["Andrew Phillips", "Nermin Šerifović"] +publisher: Artima Press +publisherLink: http://www.artima.com/index.jsp +--- + +"Getting code to do what we want it to do is perhaps the essence of our purpose as developers. So there are few things more intriguing or important than code that we think we understand, but that behaves rather contrary to our expectations. Scala Puzzlers is a collection of such examples in Scala. It is not only an entertaining and instructive way of understanding this highly expressive language better. It will also help you recognize many counter-intuitive traps and pitfalls and prevent them from inflicting further production bug hunt stress on Scala developers." diff --git a/_config.yml b/_config.yml index e6e6343bf4..da1e6599c1 100644 --- a/_config.yml +++ b/_config.yml @@ -15,11 +15,72 @@ keywords: - Document - Guide -scala-version: 2.12.0 +scala-version: 2.12.2 + +collections: + style: + output: true + overviews: + output: true + tour: + output: true + permalink: /:collection/:path.html + tutorials: + output: true + permalink: /:collection/:path.html + sips: + output: true + permalink: /:collection/:path.html + books: + output: false + ja: # Japanese translations + output: true + permalink: /:collection/:path.html + zh-cn: # Chinese (Simplified) translations + output: true + permalink: /:collection/:path.html + ru: # Russian translations + output: true + permalink: /:collection/:path.html + es: # Spanish translations + output: true + permalink: /:collection/:path.html + ba: # Bosnian translations + output: true + permalink: /:collection/:path.html + pl: # Polish translations + output: true + permalink: /:collection/:path.html + pt-br: # Brazilian Portuguese translations + output: true + permalink: /:collection/:path.html + ko: # Korean translations + output: true + permalink: /:collection/:path.html + de: # German translations + output: true + permalink: /:collection/:path.html + it: # Italian translations + output: true + permalink: /:collection/:path.html + zh-tw: # Taiwanese translations + output: true + permalink: /:collection/:path.html + fr: # French translations + output: true + permalink: /:collection/:path.html + +defaults: + - + scope: + path: "" + type: "tour" + values: + overview-name: "Tour of Scala" highlighter: rouge -permalink: /:categories/:title.html +permalink: /:categories/:title.html:output_ext baseurl: exclude: ["vendor"] -gems: +plugins: - jekyll-redirect-from diff --git a/_data/doc-nav-header.yml b/_data/doc-nav-header.yml new file mode 100644 index 0000000000..e3962dd19e --- /dev/null +++ b/_data/doc-nav-header.yml @@ -0,0 +1,37 @@ +- title: API + url: "#" + submenu: + - title: Current + url: https://www.scala-lang.org/api/current/ + - title: Nightly + url: https://www.scala-lang.org/files/archive/nightly/2.12.x/api/2.12.x/ + - title: All Versions + url: "/api/all.html" +- title: Learn + url: "#" + submenu: + - title: Getting Started + url: "/getting-started.html" + - title: Tour of Scala + url: "/tour/tour-of-scala.html" + - title: Scala for Java Programmers + url: "/tutorials/scala-for-java-programmers.html" +- title: Reference + url: "#" + submenu: + - title: "Guides & Overviews" + url: "/overviews/index.html" + - title: Books + url: "/books.html" + - title: Scala FAQs + url: "/tutorials/FAQ/index.html" + - title: Language Spec + url: http://scala-lang.org/files/archive/spec/2.12/ +- title: Style Guide + url: "/style/index.html" +- title: Cheatsheet + url: "/cheatsheets/index.html" +- title: Glossary + url: "/glossary/index.html" +- title: SIPs + url: "/sips/index.html" diff --git a/_data/docnames.yml b/_data/docnames.yml new file mode 100644 index 0000000000..7a8ddf97b9 --- /dev/null +++ b/_data/docnames.yml @@ -0,0 +1,8 @@ +scala-tour: + name: "Tour of Scala" + +futures: + name: "Futures" + +cheatsheet: + name: "Scala Cheatsheet" diff --git a/_data/footer.yml b/_data/footer.yml new file mode 100644 index 0000000000..04e60f45eb --- /dev/null +++ b/_data/footer.yml @@ -0,0 +1,54 @@ +- title: Documentation + class: documentation + links: + - title: Getting Started + url: "/getting-started.html" + - title: API + url: "https://www.scala-lang.org/api/current/index.html" + - title: Overviews/Guides + url: "/overviews" + - title: Language Specification + url: "http://scala-lang.org/files/archive/spec/2.12/" +- title: Download + class: download + links: + - title: Current Version + url: "http://scala-lang.org/download/" + - title: All versions + url: "http://scala-lang.org/download/all.html" +- title: Community + class: community + links: + - title: Community + url: "http://scala-lang.org/community/" + - title: Mailing Lists + url: "http://scala-lang.org/community/index.html#mailing-lists" + - title: Chat Rooms & More + url: "http://scala-lang.org/community/index.html#chat-rooms" + - title: Libraries and Tools + url: "http://scala-lang.org/community/index.html#community-libraries-and-tools" + - title: "The Scala Center" + url: "http://scala.epfl.ch/" +- title: Contribute + class: contribute + links: + - title: How to help + url: "http://scala-lang.org/contribute/" + - title: Report an Issue + url: "http://scala-lang.org/contribute/bug-reporting-guide.html" +- title: Scala + class: scala + links: + - title: Blog + url: "http://scala-lang.org/blog/" + - title: Code of Conduct + url: "http://scala-lang.org/conduct/" + - title: License + url: "http://scala-lang.org/license/" +- title: Social + class: social + links: + - title: GitHub + url: "https://github.com/scala/scala" + - title: Twitter + url: "https://twitter.com/scala_lang" diff --git a/_data/nav-header.yml b/_data/nav-header.yml new file mode 100644 index 0000000000..fc7def1c8f --- /dev/null +++ b/_data/nav-header.yml @@ -0,0 +1,12 @@ +- title: Documentation + url: "" +- title: Download + url: https://www.scala-lang.org/download/ +- title: Community + url: https://www.scala-lang.org/community/ +- title: Libraries + url: https://index.scala-lang.org +- title: Contribute + url: https://www.scala-lang.org/contribute/ +- title: Blog + url: https://www.scala-lang.org/blog/ diff --git a/_data/overviews.yml b/_data/overviews.yml new file mode 100644 index 0000000000..05fa535e3f --- /dev/null +++ b/_data/overviews.yml @@ -0,0 +1,223 @@ + +- category: Core Scala + description: "Guides and overviews covering central libraries in the Scala standard library, core language features, and more." + overviews: + - title: Collections + by: Martin Odersky + icon: sitemap + url: "collections/introduction.html" + description: "Scala's Collection Library." + subdocs: + - title: Introduction + url: "collections/introduction.html" + - title: Mutable and Immutable Collections + url: "collections/overview.html" + - title: Trait Traversable + url: "collections/trait-traversable.html" + - title: Trait Iterable + url: "collections/trait-iterable.html" + - title: The sequence traits Seq, IndexedSeq, and LinearSeq + - title: Concrete Immutable Collection Classes + url: "collections/concrete-immutable-collection-classes.html" + - title: Concrete Mutable Collection Classes + url: "collections/concrete-mutable-collection-classes.html" + - title: Arrays + url: "collections/arrays.html" + - title: Strings + url: "collections/strings.html" + - title: Performance Characteristics + url: "collections/performance-characteristics.html" + - title: Equality + url: "collections/equality.html" + - title: Views + url: "collections/views.html" + - title: Iterators + url: "collections/iterators.html" + - title: Creating Collections From Scratch + url: "collections/creating-collections-from-scratch.html" + - title: Conversions Between Java and Scala Collections + url: "collections/conversions-between-java-and-scala-collections.html" + - title: The Architecture of Scala Collections + icon: building + url: "core/architecture-of-scala-collections.html" + by: Martin Odersky and Lex Spoon + description: "These pages describe the architecture of the Scala collections framework in detail. Compared to the Collections API you will find out more about the internal workings of the framework. You will also learn how this architecture helps you define your own collections in a few lines of code, while reusing the overwhelming part of collection functionality from the framework." + - title: String Interpolation + icon: usd + url: "core/string-interpolation.html" + description: > + String Interpolation allows users to embed variable references directly in processed string literals. Here’s an example: +
val name = "James"
+          println(s"Hello, $name")  // Hello, James
+ In the above, the literal s"Hello, $name" is a processed string literal. This means that the compiler does some additional work to this literal. A processed string literal is denoted by a set of characters preceding the ". String interpolation was introduced by SIP-11, which contains all details of the implementation. + - title: Implicit Classes + by: Josh Suereth + description: "Scala 2.10 introduced a new feature called implicit classes. An implicit class is a class marked with the implicit keyword. This keyword makes the class’ primary constructor available for implicit conversions when the class is in scope." + url: "core/implicit-classes.html" + - title: Value Classes and Universal Traits + by: Mark Harrah + description: "Value classes are a new mechanism in Scala to avoid allocating runtime objects. This is accomplished through the definition of new AnyVal subclasses." + icon: diamond + url: "core/value-classes.html" + - title: Binary Compatibility of Scala Releases + description: "When two versions of Scala are binary compatible, it is safe to compile your project on one Scala version and link against another Scala version at run time. Safe run-time linkage (only!) means that the JVM does not throw a (subclass of) LinkageError when executing your program in the mixed scenario, assuming that none arise when compiling and running on the same version of Scala. Concretely, this means you may have external dependencies on your run-time classpath that use a different version of Scala than the one you’re compiling with, as long as they’re binary compatible. In other words, separate compilation on different binary compatible versions does not introduce problems compared to compiling and running everything on the same version of Scala." + icon: puzzle-piece + url: "core/binary-compatibility-of-scala-releases.html" + - title: Binary Compatibility for library authors + description: "A diverse and comprehensive set of libraries is important to any productive software ecosystem. While it is easy to develop and distribute Scala libraries, good library authorship goes beyond just writing code and publishing it. In this guide, we cover the important topic of Binary Compatibility." + icon: puzzle-piece + url: "core/binary-compatibility-for-library-authors.html" + +- category: "Reference/Documentation" + description: "Reference material on core Scala tools like Scaladoc and the Scala REPL." + overviews: + - title: Scaladoc + url: "scaladoc/overview.html" + icon: book + description: "Scala's API documentation generation tool." + subdocs: + - title: Overview + url: "scaladoc/overview.html" + - title: Scaladoc for Library Authors + url: "scaladoc/for-library-authors.html" + - title: Using the Scaladoc Interface + url: "scaladoc/interface.html" + - title: Scala REPL + icon: terminal + url: "repl/overview.html" + description: | + The Scala REPL is a tool (scala) for evaluating expressions in Scala. +

+ The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program + +- category: Parallel and Concurrent Programming + description: "Complete guides covering some of Scala's libraries for parallel and concurrent programming." + overviews: + - title: Futures and Promises + by: "Philipp Haller, Aleksandar Prokopec, Heather Miller, Viktor Klang, Roland Kuhn, and Vojin Jovanovic" + icon: tasks + url: "core/futures.html" + description: "Futures provide a way to reason about performing many operations in parallel– in an efficient and non-blocking way. A Future is a placeholder object for a value that may not yet exist. Generally, the value of the Future is supplied concurrently and can subsequently be used. Composing concurrent tasks in this way tends to result in faster, asynchronous, non-blocking parallel code." + - title: Parallel Collections + by: Aleksandar Prokopec and Heather Miller + icon: rocket + url: "parallel-collections/overview.html" + description: "Scala's Parallel Collections Library." + subdocs: + - title: Overview + url: "parallel-collections/overview.html" + - title: Concrete Parallel Collection Classes + url: "parallel-collections/concrete-parallel-collections.html" + - title: Parallel Collection Conversions + url: "parallel-collections/conversions.html" + - title: Concurrent Tries + url: "parallel-collections/ctries.html" + - title: Architecture of the Parallel Collections Library + url: "parallel-collections/architecture.html" + - title: Creating Custom Parallel Collections + url: "parallel-collections/custom-parallel-collections.html" + - title: Configuring Parallel Collections + url: "parallel-collections/configuration.html" + - title: Measuring Performance + url: "parallel-collections/performance.html" + - title: The Scala Actors Migration Guide + by: Vojin Jovanovic and Philipp Haller + icon: truck + url: "core/actors-migration-guide.html" + description: "To ease the migration from Scala Actors to Akka we have provided the Actor Migration Kit (AMK). The AMK consists of an extension to Scala Actors which is enabled by including the scala-actors-migration.jar on a project’s classpath. In addition, Akka 2.1 includes features, such as the ActorDSL singleton, which enable a simpler conversion of code using Scala Actors to Akka. The purpose of this document is to guide users through the migration process and explain how to use the AMK." + - title: The Scala Actors API + by: Philipp Haller and Stephen Tu + icon: users + url: "core/actors.html" + description: "This guide describes the API of the scala.actors package of Scala 2.8/2.9. The organization follows groups of types that logically belong together. The trait hierarchy is taken into account to structure the individual sections. The focus is on the run-time behavior of the various methods that these traits define, thereby complementing the existing Scaladoc-based API documentation." + label-color: "#899295" + label-text: deprecated + +- category: Metaprogramming + description: "Guides and overviews covering the experimental reflection API introduced in Scala 2.10, and Scala's tools for metaprogramming (def macros, macro annotations, and more), also introduced in Scala 2.10" + overviews: + - title: Reflection + by: Heather Miller, Eugene Burmako, and Philipp Haller + icon: binoculars + url: "reflection/overview.html" + description: Scala's runtime/compile-time reflection framework. + label-text: experimental + subdocs: + - title: Overview + url: "reflection/overview.html" + - title: Environment, Universes, and Mirrors + url: "reflection/environment-universes-mirrors.html" + - title: Symbols, Trees, and Types + url: "reflection/symbols-trees-types.html" + - title: Annotations, Names, Scopes, and More + url: "reflection/annotations-names-scopes.html" + - title: TypeTags and Manifests + url: "reflection/typetags-manifests.html" + - title: Thread Safety + url: "reflection/thread-safety.html" + - title: Changes in Scala 2.11 + url: "reflection/changelog211.html" + - title: Macros + by: Eugene Burmako + icon: magic + url: "macros/usecases.html" + description: "Scala's metaprogramming framework." + label-text: experimental + subdocs: + - title: Use Cases + url: "macros/usecases.html" + - title: Blackbox Vs Whitebox + url: "macros/blackbox-whitebox.html" + - title: Def Macros + url: "macros/overview.html" + - title: Quasiquotes + url: "quasiquotes/intro.html" + - title: Macro Bundles + url: "macros/bundles.html" + - title: Implicit Macros + url: "macros/implicits.html" + - title: Extractor Macros + url: "macros/extractors.html" + - title: Type Providers + url: "macros/typeproviders.html" + - title: Macro Annotations + url: "macros/annotations.html" + - title: Macro Paradise + url: "macros/paradise.html" + - title: Roadmap + url: "macros/roadmap.html" + - title: Changes in 2.11 + url: "macros/changelog211.html" + - title: Quasiquotes + by: Denys Shabalin + icon: quote-left + url: "quasiquotes/setup.html" + description: "Quasiquotes are a convenient way to manipulate Scala syntax trees." + label-text: experimental + subdocs: + - title: Dependencies and setup + url: "quasiquotes/setup.html" + - title: Introduction + url: "quasiquotes/intro.html" + - title: Lifting + url: "quasiquotes/lifting.html" + - title: Unlifting + url: "quasiquotes/unlifting.html" + - title: Hygiene + url: "quasiquotes/hygiene.html" + - title: Use cases + url: "quasiquotes/usecases.html" + - title: Syntax summary + url: "quasiquotes/syntax-summary.html" + - title: Expression details + url: "quasiquotes/expression-details.html" + - title: Type details + url: "quasiquotes/type-details.html" + - title: Pattern details + url: "quasiquotes/pattern-details.html" + - title: Definition and import details + url: "quasiquotes/definition-details.html" + - title: Terminology summary + url: "quasiquotes/terminology.html" + - title: Future prospects + url: "quasiquotes/future.html" diff --git a/_data/sip-data.yml b/_data/sip-data.yml new file mode 100644 index 0000000000..6a6b19fe68 --- /dev/null +++ b/_data/sip-data.yml @@ -0,0 +1,27 @@ +under-review: + color: "#b58900" + text: "Under Review" + +pending: + color: "#b58900" + text: "Pending" + +dormant: + color: "#839496" + text: "Dormant" + +under-revision: + color: "#2aa198" + text: "Under Revision" + +accepted: + color: "#859900" + text: "Accepted" + +complete: + color: "#859900" + text: "Complete" + +rejected: + color: "#dc322f" + text: "Rejected" diff --git a/_data/translations.yml b/_data/translations.yml new file mode 100644 index 0000000000..afbfdbb6f4 --- /dev/null +++ b/_data/translations.yml @@ -0,0 +1,2 @@ +tour: + languages: [ba, es, ko, pt-br, pl] diff --git a/de/tutorials/scala-for-java-programmers.md b/_de/tutorials/scala-for-java-programmers.md similarity index 99% rename from de/tutorials/scala-for-java-programmers.md rename to _de/tutorials/scala-for-java-programmers.md index ca28395c75..451cc0a940 100644 --- a/de/tutorials/scala-for-java-programmers.md +++ b/_de/tutorials/scala-for-java-programmers.md @@ -1,10 +1,10 @@ --- -layout: overview +layout: singlepage-overview title: Ein Scala Tutorial für Java Programmierer -overview: scala-for-java-programmers -disqus: true -multilingual-overview: true +partof: scala-for-java-programmers + +discourse: false language: de --- @@ -631,4 +631,3 @@ Dieses Dokument hat einen kurzen Überblick über die Sprache Scala gegeben und Beispiele verwendet. Interessierte Leser können beispielsweise mit dem Dokument *Scala by Example* fortfahren, welches fortgeschrittenere Beispiele enthält, und die *Scala Language Specification* konsultieren, sofern nötig. - diff --git a/es/overviews/core/actors.md b/_es/overviews/core/actors.md similarity index 99% rename from es/overviews/core/actors.md rename to _es/overviews/core/actors.md index 498fd6abf6..8c74bcf92e 100644 --- a/es/overviews/core/actors.md +++ b/_es/overviews/core/actors.md @@ -1,10 +1,12 @@ --- -layout: overview +layout: singlepage-overview title: API de actores en Scala -label-color: success -label-text: Available + +partof: actors + language: es -overview: actors + +discourse: false --- **Philipp Haller and Stephen Tu** diff --git a/es/overviews/core/string-interpolation.md b/_es/overviews/core/string-interpolation.md similarity index 97% rename from es/overviews/core/string-interpolation.md rename to _es/overviews/core/string-interpolation.md index 0fba485b10..392a0b68ac 100644 --- a/es/overviews/core/string-interpolation.md +++ b/_es/overviews/core/string-interpolation.md @@ -1,11 +1,12 @@ --- -layout: overview +layout: singlepage-overview title: Interpolación de cadenas -disqus: true -label-color: success -label-text: New in 2.10 + +partof: string-interpolation + language: es -overview: string-interpolation + +discourse: false --- **Josh Suereth** @@ -39,7 +40,7 @@ Las interpolaciones pueden recibir expresiones arbitrarias. Por ejemplo: println(s"1 + 1 = ${1 + 1}") -imprimirá la cadena `1 + 1 = 2`. Cualquier expresión puede ser embebida en `${}` +imprimirá la cadena `1 + 1 = 2`. Cualquier expresión puede ser embebida en `${}` ### Interpolador `f` @@ -52,7 +53,7 @@ Prefijando `f` a cualquier cadena permite llevar a cabo la creación de cadenas El interpolador `f` es seguro respecto a tipos. Si pasamos un número real a una cadena de formateo que sólo funciona con números enteros, el compilador emitirá un error. Por ejemplo: val height: Double = 1.9d - + scala> f"$height%4d" :9: error: type mismatch; found : Double @@ -67,7 +68,7 @@ El interpolador `f` hace uso de las utilidades de formateo de cadenas disponible El interpolador `raw` difiere del interpolador `s` en que el primero no realiza el escapado de literales contenidos en la cadena. A continuación se muestra un ejemplo de una cadena procesada: scala> s"a\nb" - res0: String = + res0: String = a b @@ -88,14 +89,14 @@ En Scala, todas las cadenas "procesadas" son simples transformaciones de código la transforma en la llamada a un método (`id`) sobre una instancia de [StringContext](http://www.scala-lang.org/api/current/index.html#scala.StringContext). Este método también puede estar disponible en un ámbito implícito. Para definiir nuestra propia cadena de interpolación simplemente necesitamos crear una clase implícita que añada un nuevo método a la clase `StringContext`. A continuación se muestra un ejemplo: - // Note: We extends AnyVal to prevent runtime instantiation. See + // Note: We extends AnyVal to prevent runtime instantiation. See // value class guide for more info. implicit class JsonHelper(val sc: StringContext) extends AnyVal { def json(args: Any*): JSONObject = sys.error("TODO - IMPLEMENT") } - + def giveMeSomeJson(x: JSONObject): Unit = ... - + giveMeSomeJson(json"{ name: $name, id: $id }") En este ejemplo, estamos intentando crear una cadena JSON mediante el uso de la interpolación de cadenas. La clase implícita `JsonHelper` debe estar disponible en el ámbito donde deseemos utilizar esta sintaxis, y el método `json` necesitaría ser implementado completamente. Sin embargo, el resutlado de dicha cadena de formateo no sería una cadena sino un objeto de tipo `JSONObject` diff --git a/es/overviews/parallel-collections/architecture.md b/_es/overviews/parallel-collections/architecture.md similarity index 92% rename from es/overviews/parallel-collections/architecture.md rename to _es/overviews/parallel-collections/architecture.md index 3c635555d7..fa8d146b00 100644 --- a/es/overviews/parallel-collections/architecture.md +++ b/_es/overviews/parallel-collections/architecture.md @@ -1,10 +1,12 @@ --- -layout: overview-large +layout: multipage-overview title: Arquitectura de la librería de colecciones paralelas de Scala -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 5 language: es --- @@ -12,16 +14,16 @@ language: es Del mismo modo que la librería de colecciones secuencial, la versión paralela ofrece un gran número de operaciones uniformes sobre un amplio abanico de implementaciones de diversas colecciones. Siguiendo la filosofía de la versión -secuencial, se pretende evitar la duplicación de código mediante el uso de +secuencial, se pretende evitar la duplicación de código mediante el uso de "plantillas" de colecciones paralelas, las cuales permiten que las operaciones sean definidas una sola vez, pudiendo ser heredadas por las diferentes implementaciones. El uso de este enfoque facilita de manera notable el **mantenimiento** y la **extensibilidad** -de la librería. En el caso del primero -- gracias a que cada operación se implementa una única -vez y es heredada por todas las colecciones, el mantenimiento es más sencillo y robusto; la -corrección de posibles errores se progaga hacia abajo en la jerarquía de clases en lugar de -duplicar las implementaciones. Del mismo modo, los motivos anteriores facilitan que la librería al completo sea -más sencilla de extender -- la mayor parte de las nuevas colecciones podrán heredar la mayoría de sus +de la librería. En el caso del primero -- gracias a que cada operación se implementa una única +vez y es heredada por todas las colecciones, el mantenimiento es más sencillo y robusto; la +corrección de posibles errores se progaga hacia abajo en la jerarquía de clases en lugar de +duplicar las implementaciones. Del mismo modo, los motivos anteriores facilitan que la librería al completo sea +más sencilla de extender -- la mayor parte de las nuevas colecciones podrán heredar la mayoría de sus operaciones. ## Core Abstractions @@ -33,7 +35,7 @@ de dos abstracciones básicas -- `Splitter`s y `Combiner`s El trabajo de un `Splitter`, como su propio nombre indica, consiste en dividir una colección paralela en una partición no trivial de sus elementos. La idea principal -es dividir dicha colección en partes más pequeñas hasta alcanzar un tamaño en el que +es dividir dicha colección en partes más pequeñas hasta alcanzar un tamaño en el que se pueda operar de manera secuencial sobre las mismas. trait Splitter[T] extends Iterator[T] { @@ -41,8 +43,8 @@ se pueda operar de manera secuencial sobre las mismas. } Curiosamente, los `Splitter` son implementados como `Iterator`s, por lo que además de -particionar, son utilizados por el framework para recorrer una colección paralela -(dado que heredan los métodos `next`y `hasNext` presentes en `Iterator`). +particionar, son utilizados por el framework para recorrer una colección paralela +(dado que heredan los métodos `next`y `hasNext` presentes en `Iterator`). Este "splitting iterator" presenta una característica única: su método `split` divide `this` (recordad que un `Splitter` es de tipo `Iterator`) en un conjunto de `Splitter`s cada uno de los cuales recorre un subconjunto disjunto del total de @@ -51,7 +53,7 @@ un `Splitter` es invalidado una vez su método `split` es invocado. Generalmente las colecciones son divididas, utilizando `Splitter`s, en subconjuntos con un tamaño aproximadamente idéntico. En situaciones donde se necesitan un tipo de -particiones más arbitrarias, particularmente en las secuencias paralelas, se utiliza un +particiones más arbitrarias, particularmente en las secuencias paralelas, se utiliza un `PreciseSplitter`, el cual hereda de `Splitter` y define un meticuloso método de particionado: `psplit`. @@ -67,14 +69,14 @@ Mientras que en las colecciones secuenciales los elementos pueden ser añadidos `result`, en el caso de las colecciones paralelas los `Combiner` presentan un método llamado `combine` que acepta otro `Combiner`como argumento y retona un nuevo `Combiner`, el cual contiene la unión de ambos. Tras la invocación del método `combine` ambos -`Combiner` son invalidados. +`Combiner` son invalidados. trait Combiner[Elem, To] extends Builder[Elem, To] { def combine(other: Combiner[Elem, To]): Combiner[Elem, To] } Los dos parametros de tipo `Elem` y `To` presentes en el fragmento de código anterior -representan el tipo del elemento y de la colección resultante respectivamente. +representan el tipo del elemento y de la colección resultante respectivamente. _Nota:_ Dados dos `Combiner`s, `c1` y `c2` donde `c1 eq c2` toma el valor `true` (esto implica que son el mismo `Combiner`), la invocación de `c1.combine(c2)` @@ -94,10 +96,10 @@ a continuación.
El objetivo es, por supuesto, integrar tan estrechamente como sea posible las colecciones -secuenciales y paralelas, permitendo llevar a cabo una sustitución directa entre ambos +secuenciales y paralelas, permitendo llevar a cabo una sustitución directa entre ambos tipos de colecciones. -Con el objetivo de tener una referencia a una colección que podría ser secuencial o +Con el objetivo de tener una referencia a una colección que podría ser secuencial o paralela (de modo que sea posible "intercambiar" la colección paralela y la secuencial mediante la invocación de `par` y `seq` respectivamente), necesitamos un supertipo común a los tipos de las dos colecciones. Este es el origen de los traits "generales" mostrados diff --git a/es/overviews/parallel-collections/concrete-parallel-collections.md b/_es/overviews/parallel-collections/concrete-parallel-collections.md similarity index 99% rename from es/overviews/parallel-collections/concrete-parallel-collections.md rename to _es/overviews/parallel-collections/concrete-parallel-collections.md index 091d59225c..f8c65f1e3b 100644 --- a/es/overviews/parallel-collections/concrete-parallel-collections.md +++ b/_es/overviews/parallel-collections/concrete-parallel-collections.md @@ -1,10 +1,12 @@ --- -layout: overview-large +layout: multipage-overview title: Clases Concretas de las Colecciones Paralelas -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 2 language: es --- @@ -15,10 +17,10 @@ Una secuencia [ParArray](http://www.scala-lang.org/api/{{ site.scala-version }}/ scala> val pa = scala.collection.parallel.mutable.ParArray.tabulate(1000)(x => 2 * x + 1) pa: scala.collection.parallel.mutable.ParArray[Int] = ParArray(1, 3, 5, 7, 9, 11, 13,... - + scala> pa reduce (_ + _) res0: Int = 1000000 - + scala> pa map (x => (x - 1) / 2) res1: scala.collection.parallel.mutable.ParArray[Int] = ParArray(0, 1, 2, 3, 4, 5, 6, 7,... @@ -33,7 +35,7 @@ Un [ParVector](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/coll scala> val pv = scala.collection.parallel.immutable.ParVector.tabulate(1000)(x => x) pv: scala.collection.parallel.immutable.ParVector[Int] = ParVector(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,... - + scala> pv filter (_ % 2 == 0) res0: scala.collection.parallel.immutable.ParVector[Int] = ParVector(0, 2, 4, 6, 8, 10, 12, 14, 16, 18,... @@ -47,7 +49,7 @@ Un [ParRange](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/colle scala> 1 to 3 par res0: scala.collection.parallel.immutable.ParRange = ParRange(1, 2, 3) - + scala> 15 to 5 by -2 par res1: scala.collection.parallel.immutable.ParRange = ParRange(15, 13, 11, 9, 7, 5) @@ -63,7 +65,7 @@ Las tablas hash paralelas almacenan sus elementos en un array subyacente y los a scala> val phs = scala.collection.parallel.mutable.ParHashSet(1 until 2000: _*) phs: scala.collection.parallel.mutable.ParHashSet[Int] = ParHashSet(18, 327, 736, 1045, 773, 1082,... - + scala> phs map (x => x * x) res0: scala.collection.parallel.mutable.ParHashSet[Int] = ParHashSet(2181529, 2446096, 99225, 2585664,... @@ -73,13 +75,13 @@ Los "Mapas Hash" (Hash Maps) y los "Conjuntos Hash" (Hash Sets) secuenciales pue ## Hash Tries Paralelos -Los Hash Tries paralelos son la contraparte paralela de los hash tries inmutables, que son usados para representar conjuntos y mapas inmutables de forma eficiente. Las clases involucradas son: [immutable.ParHashSet](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/parallel/immutable/ParHashSet.html) +Los Hash Tries paralelos son la contraparte paralela de los hash tries inmutables, que son usados para representar conjuntos y mapas inmutables de forma eficiente. Las clases involucradas son: [immutable.ParHashSet](http://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/parallel/immutable/ParHashSet.html) y [immutable.ParHashMap](http://www.scala-lang.org/api/{{ site.scala-version}}/scala/collection/parallel/immutable/ParHashMap.html). scala> val phs = scala.collection.parallel.immutable.ParHashSet(1 until 1000: _*) phs: scala.collection.parallel.immutable.ParHashSet[Int] = ParSet(645, 892, 69, 809, 629, 365, 138, 760, 101, 479,... - + scala> phs map { x => x * x } sum res0: Int = 332833500 @@ -94,12 +96,12 @@ Un [concurrent.TrieMap](http://www.scala-lang.org/api/{{ site.scala-version }}/s scala> val numbers = scala.collection.parallel.mutable.ParTrieMap((1 until 100) zip (1 until 100): _*) map { case (k, v) => (k.toDouble, v.toDouble) } numbers: scala.collection.parallel.mutable.ParTrieMap[Double,Double] = ParTrieMap(0.0 -> 0.0, 42.0 -> 42.0, 70.0 -> 70.0, 2.0 -> 2.0,... - + scala> while (numbers.nonEmpty) { | numbers foreach { case (num, sqrt) => | val nsqrt = 0.5 * (sqrt + num / sqrt) | numbers(num) = nsqrt - | if (math.abs(nsqrt - sqrt) < 0.01) { + | if (math.abs(nsqrt - sqrt) < 0.01) { | println(num, nsqrt) | numbers.remove(num) | } @@ -170,15 +172,3 @@ La segunda tabla trata sets y maps, tanto mutables como inmutables, con las sigu | **remove** | Removing an element from a set or a key from a map. | | **remove** | Elimina un elemento de un set o una clave de un map. | | **min** | El menor elemento de un set o la menor clave de un mapa. | - - - - - - - - - - - - diff --git a/es/overviews/parallel-collections/configuration.md b/_es/overviews/parallel-collections/configuration.md similarity index 96% rename from es/overviews/parallel-collections/configuration.md rename to _es/overviews/parallel-collections/configuration.md index 1de79dbd1d..6e921bc9a5 100644 --- a/es/overviews/parallel-collections/configuration.md +++ b/_es/overviews/parallel-collections/configuration.md @@ -1,17 +1,19 @@ --- -layout: overview-large +layout: multipage-overview title: Configurando las colecciones paralelas -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 7 language: es --- ## "Task support" -Las colecciones paralelas son modulares respecto al modo en que las operaciones +Las colecciones paralelas son modulares respecto al modo en que las operaciones son planificadas. Cada colección paralela es planificada con un objeto "task support" el cual es responsable de la planificación y el balanceo de las tareas a los distintos procesadores. @@ -20,7 +22,7 @@ El objeto "task support" mantiene internamente un referencia a un pool de hilos cómo y cuando las tareas son divididas en tareas más pequeñas. Para conocer más en detalle cómo funciona internamente diríjase al informe técnico \[[1][1]\]. -En la actualidad las colecciones paralelas disponen de unas cuantas implementaciones de +En la actualidad las colecciones paralelas disponen de unas cuantas implementaciones de "task support". El `ForkJoinTaskSupport` utiliza internamente un fork-join pool y es utilizado por defecto en JVM 1.6 o superiores. `ThreadPoolTaskSupport`, menos eficiente, es utilizado como mecanismo de reserva para JVM 1.5 y máquinas virtuales que no soporten los fork join pools. El @@ -34,13 +36,13 @@ A continuación se muestra cómo se puede modificar el objeto "task support" de scala> import scala.collection.parallel._ import scala.collection.parallel._ - + scala> val pc = mutable.ParArray(1, 2, 3) pc: scala.collection.parallel.mutable.ParArray[Int] = ParArray(1, 2, 3) - + scala> pc.tasksupport = new ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(2)) pc.tasksupport: scala.collection.parallel.TaskSupport = scala.collection.parallel.ForkJoinTaskSupport@4a5d484a - + scala> pc map { _ + 1 } res0: scala.collection.parallel.mutable.ParArray[Int] = ParArray(2, 3, 4) @@ -49,7 +51,7 @@ paralelismo. Para indicar que la colección utilice un thread pool executor tend scala> pc.tasksupport = new ThreadPoolTaskSupport() pc.tasksupport: scala.collection.parallel.TaskSupport = scala.collection.parallel.ThreadPoolTaskSupport@1d914a39 - + scala> pc map { _ + 1 } res1: scala.collection.parallel.mutable.ParArray[Int] = ParArray(2, 3, 4) @@ -62,9 +64,9 @@ Para llevar a cabo una implementación personalizada de un nuevo objeto "task su extender del trait `TaskSupport` e implementar los siguientes métodos: def execute[R, Tp](task: Task[R, Tp]): () => R - + def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R - + def parallelismLevel: Int El método `execute` planifica una tarea asíncrona y retorna una "future" sobre la que diff --git a/es/overviews/parallel-collections/conversions.md b/_es/overviews/parallel-collections/conversions.md similarity index 95% rename from es/overviews/parallel-collections/conversions.md rename to _es/overviews/parallel-collections/conversions.md index a32790c9d2..8461a2f9aa 100644 --- a/es/overviews/parallel-collections/conversions.md +++ b/_es/overviews/parallel-collections/conversions.md @@ -1,9 +1,11 @@ --- -layout: overview-large +layout: multipage-overview title: Conversiones en colecciones paralelas -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 3 language: es --- @@ -18,7 +20,7 @@ versiones utilizan la misma estructura de datos interna. Una excepción al caso anterior es el caso de los hash maps y hash sets mutables, donde el proceso de conversión es un poco más costoso la primera vez que el método `par` es llamado, aunque las posteriores invocaciones de dicho método ofrecerán un tiempo de ejecución -constante. Nótese que en el caso de las colecciones mutables, los cambios en la +constante. Nótese que en el caso de las colecciones mutables, los cambios en la colección secuencial son visibles en su homóloga paralela en el caso de que compartan la estructura de datos subyacente. @@ -38,7 +40,7 @@ la estructura de datos subyacente. Otro tipo de colecciones, como las listas, colas o `streams`, son inherentemente secuenciales en el sentido de que los elementos deben ser accedidos uno tras otro. La versión paralela de estas estructuras se obtiene mediante la copia de los elementos -en una colección paralela. Por ejemplo, una lista funcional es convertida en una +en una colección paralela. Por ejemplo, una lista funcional es convertida en una secuencia paralela inmutable; un vector paralelo. Cada colección paralela puede ser convertida a su variante secuencial mediante el uso @@ -50,8 +52,8 @@ colecciones serán visibles en la otra. ## Conversiones entre diferentes tipo de colecciones -Ortogonal a la conversión entre colecciones secuenciales y paralelas, las colecciones -pueden convertirse entre diferentes tipos. Por ejemplo, la llamada al método `toSeq` +Ortogonal a la conversión entre colecciones secuenciales y paralelas, las colecciones +pueden convertirse entre diferentes tipos. Por ejemplo, la llamada al método `toSeq` convierte un conjunto secuencial en una secuencia secuencial, mientras que si invocamos dicho método sobre un conjunto paralelo obtendremos una secuencia paralela. La regla general is que si existe una versión paralela de `X`, el método `toX` convierte la colección @@ -72,6 +74,3 @@ A continuación se muestra un resumen de todos los métodos de conversión: | `toSeq` | `ParSeq` | | `toSet` | `ParSet` | | `toMap` | `ParMap` | - - - diff --git a/es/overviews/parallel-collections/ctries.md b/_es/overviews/parallel-collections/ctries.md similarity index 94% rename from es/overviews/parallel-collections/ctries.md rename to _es/overviews/parallel-collections/ctries.md index d3da24823f..c45a112520 100644 --- a/es/overviews/parallel-collections/ctries.md +++ b/_es/overviews/parallel-collections/ctries.md @@ -1,10 +1,12 @@ --- -layout: overview-large +layout: multipage-overview title: Tries Concurrentes -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 4 language: es --- @@ -14,9 +16,9 @@ si la estructura es modificada durante el recorrido de la misma. De hecho, esto también sucede en la mayor parte de las colecciones mutables. Los "tries" concurrentes presentan una característica especial, permitiendo la modificación de los mismos mientras están siendo recorridos. Las modificaciones solo son visibles -en los recorridos posteriores a las mismas. Ésto aplica tanto a los "tries" secuenciales +en los recorridos posteriores a las mismas. Ésto aplica tanto a los "tries" secuenciales como a los paralelos. La única diferencia entre ambos es que el primero de ellos -recorre todos los elementos de la estructura de manera secuencial mientras que +recorre todos los elementos de la estructura de manera secuencial mientras que el segundo lo hace en paralelo. Esta propiedad nos permite escribir determinados algoritmos de un modo mucho más @@ -25,20 +27,20 @@ iterativa y diferentes elementos necesitan distinto número de iteraciones para procesados. El siguiente ejemplo calcula la raíz cuadrada de un conjunto de números. Cada iteración -actualiza, de manera iterativa, el valor de la raíz cuadrada. Aquellos números cuyas +actualiza, de manera iterativa, el valor de la raíz cuadrada. Aquellos números cuyas raíces convergen son eliminados del mapa. case class Entry(num: Double) { var sqrt = num } - + val length = 50000 - + // prepare the list val entries = (1 until length) map { num => Entry(num.toDouble) } val results = ParTrieMap() for (e <- entries) results += ((e.num, e)) - + // compute square roots while (results.nonEmpty) { for ((num, e) <- results) { @@ -56,45 +58,45 @@ elementos sobre los que realmente necesitamos trabajar son recorridos. Otro ejemplo es el algoritmo de búsqueda en anchura, el cual iterativamente expande el "nodo cabecera" hasta que encuentra un camino hacia el objetivo o no existen más nodos a expandir. Definamos -un nodo en mapa 2D como una tupla de enteros (`Int`s). Definamos un `map` como un array de +un nodo en mapa 2D como una tupla de enteros (`Int`s). Definamos un `map` como un array de booleanos de dos dimensiones el cual determina si un determinado slot está ocupado o no. Posteriormente, -declaramos dos "concurrent tries maps" -- `open` contiene todos los nodos que deben ser expandidos +declaramos dos "concurrent tries maps" -- `open` contiene todos los nodos que deben ser expandidos ("nodos cabecera") mientras que `close` continene todos los nodos que ya han sido expandidos. Comenzamos -la búsqueda desde las esquinas del mapa en busca de un camino hasta el centro del mismo -- -e inicializamos el mapa `open` con los nodos apropiados. Iterativamamente, y en paralelo, +la búsqueda desde las esquinas del mapa en busca de un camino hasta el centro del mismo -- +e inicializamos el mapa `open` con los nodos apropiados. Iterativamamente, y en paralelo, expandimos todos los nodos presentes en el mapa `open` hasta que agotamos todos los elementos que necesitan ser expandidos. Cada vez que un nodo es expandido, se elimina del mapa `open` y se -añade en el mapa `closed`. Una vez finalizado el proceso, se muestra el camino desde el nodo +añade en el mapa `closed`. Una vez finalizado el proceso, se muestra el camino desde el nodo destino hasta el nodo inicial. - + val length = 1000 - + // define the Node type type Node = (Int, Int); type Parent = (Int, Int); - + // operations on the Node type def up(n: Node) = (n._1, n._2 - 1); def down(n: Node) = (n._1, n._2 + 1); def left(n: Node) = (n._1 - 1, n._2); def right(n: Node) = (n._1 + 1, n._2); - + // create a map and a target val target = (length / 2, length / 2); val map = Array.tabulate(length, length)((x, y) => (x % 3) != 0 || (y % 3) != 0 || (x, y) == target) def onMap(n: Node) = n._1 >= 0 && n._1 < length && n._2 >= 0 && n._2 < length - + // open list - the nodefront // closed list - nodes already processed val open = ParTrieMap[Node, Parent]() val closed = ParTrieMap[Node, Parent]() - + // add a couple of starting positions open((0, 0)) = null open((length - 1, length - 1)) = null open((0, length - 1)) = null open((length - 1, 0)) = null - + // greedy bfs path search while (open.nonEmpty && !open.contains(target)) { for ((node, parent) <- open) { @@ -111,7 +113,7 @@ destino hasta el nodo inicial. open.remove(node) } } - + // print path var pathnode = open(target) while (closed.contains(pathnode)) { @@ -121,11 +123,11 @@ destino hasta el nodo inicial. println() -Los "tries" concurrentes también soportan una operación atómica, no bloqueante y de +Los "tries" concurrentes también soportan una operación atómica, no bloqueante y de tiempo constante conocida como `snapshot`. Esta operación genera un nuevo `trie` -concurrente en el que se incluyen todos los elementos es un instante determinado de -tiempo, lo que en efecto captura el estado del "trie" en un punto específico. -Esta operación simplemente crea una nueva raíz para el "trie" concurrente. Posteriores +concurrente en el que se incluyen todos los elementos es un instante determinado de +tiempo, lo que en efecto captura el estado del "trie" en un punto específico. +Esta operación simplemente crea una nueva raíz para el "trie" concurrente. Posteriores actualizaciones reconstruyen, de manera perezosa, la parte del "trie" concurrente que se ha visto afectada por la actualización, manteniendo intacto el resto de la estructura. En primer lugar, esto implica que la propia operación de `snapshot` no es costosa en si misma @@ -133,7 +135,7 @@ puesto que no necesita copiar los elementos. En segundo lugar, dado que la optim "copy-and-write" solo copia determinadas partes del "trie" concurrente, las sucesivas actualizaciones escalan horizontalmente. El método `readOnlySnapshot` es ligeramente más efeciente que el método `snapshot`, pero retorna un mapa en modo solo lectura que no -puede ser modificado. Este tipo de estructura de datos soporta una operación atómica y en tiempo +puede ser modificado. Este tipo de estructura de datos soporta una operación atómica y en tiempo constante llamada `clear` la cual está basada en el anterior mecanismo de `snapshot`. Si desea conocer en más detalle cómo funcionan los "tries" concurrentes y el mecanismo de diff --git a/es/overviews/parallel-collections/custom-parallel-collections.md b/_es/overviews/parallel-collections/custom-parallel-collections.md similarity index 99% rename from es/overviews/parallel-collections/custom-parallel-collections.md rename to _es/overviews/parallel-collections/custom-parallel-collections.md index 917280f9a2..802d9f5286 100644 --- a/es/overviews/parallel-collections/custom-parallel-collections.md +++ b/_es/overviews/parallel-collections/custom-parallel-collections.md @@ -1,10 +1,12 @@ --- -layout: overview-large +layout: multipage-overview title: Creating Custom Parallel Collections -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 6 language: es --- @@ -29,7 +31,7 @@ are logically immutable sequences, we have parallel strings inherit Next, we define methods found in every immutable sequence: def apply(i: Int) = str.charAt(i) - + def length = str.length We have to also define the sequential counterpart of this parallel collection. @@ -42,12 +44,12 @@ name the splitter `ParStringSplitter` and have it inherit a sequence splitter, that is, `SeqSplitter[Char]`: def splitter = new ParStringSplitter(str, 0, str.length) - + class ParStringSplitter(private var s: String, private var i: Int, private val ntl: Int) extends SeqSplitter[Char] { final def hasNext = i < ntl - + final def next = { val r = s.charAt(i) i += 1 @@ -64,9 +66,9 @@ of elements this splitter has yet to traverse. Next, they have a method called `dup` which duplicates the current splitter. def remaining = ntl - i - + def dup = new ParStringSplitter(s, i, ntl) - + Finally, methods `split` and `psplit` are used to create splitters which traverse subsets of the elements of the current splitter. Method `split` has the contract that it returns a sequence of splitters which traverse disjoint, @@ -86,7 +88,7 @@ invalidates the current splitter. if (rem >= 2) psplit(rem / 2, rem - rem / 2) else Seq(this) } - + def psplit(sizes: Int*): Seq[ParStringSplitter] = { val splitted = new ArrayBuffer[ParStringSplitter] for (sz <- sizes) { @@ -158,28 +160,28 @@ live with this sequential bottleneck. var sz = 0 val chunks = new ArrayBuffer[StringBuilder] += new StringBuilder var lastc = chunks.last - + def size: Int = sz - + def +=(elem: Char): this.type = { lastc += elem sz += 1 this } - + def clear = { chunks.clear chunks += new StringBuilder lastc = chunks.last sz = 0 } - + def result: ParString = { val rsb = new StringBuilder for (sb <- chunks) rsb.append(sb) new ParString(rsb.toString) } - + def combine[U <: Char, NewTo >: ParString](other: Combiner[U, NewTo]) = if (other eq this) this else { val that = other.asInstanceOf[ParStringCombiner] sz += that.sz @@ -245,7 +247,7 @@ define the companion object of `ParString`. extends immutable.ParSeq[Char] with GenericParTemplate[Char, ParString] with ParSeqLike[Char, ParString, collection.immutable.WrappedString] { - + def companion = ParString Inside the companion object we provide an implicit evidence for the `CanBuildFrom` parameter. @@ -256,11 +258,11 @@ Inside the companion object we provide an implicit evidence for the `CanBuildFro def apply(from: ParString) = newCombiner def apply() = newCombiner } - + def newBuilder: Combiner[Char, ParString] = newCombiner - + def newCombiner: Combiner[Char, ParString] = new ParStringCombiner - + def apply(elems: Char*): ParString = { val cb = newCombiner cb ++= elems @@ -323,10 +325,3 @@ collection to return `false`. Such collections will fail to execute some methods which rely on splitters being strict, i.e. returning a correct value in the `remaining` method. Importantly, this does not effect methods used in for-comprehensions. - - - - - - - diff --git a/es/overviews/parallel-collections/overview.md b/_es/overviews/parallel-collections/overview.md similarity index 99% rename from es/overviews/parallel-collections/overview.md rename to _es/overviews/parallel-collections/overview.md index 13ac354f55..b5f13762f2 100644 --- a/es/overviews/parallel-collections/overview.md +++ b/_es/overviews/parallel-collections/overview.md @@ -1,10 +1,12 @@ --- -layout: overview-large +layout: multipage-overview title: Overview -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 1 language: es --- diff --git a/es/overviews/parallel-collections/performance.md b/_es/overviews/parallel-collections/performance.md similarity index 95% rename from es/overviews/parallel-collections/performance.md rename to _es/overviews/parallel-collections/performance.md index e3eb5e852d..26d2237b10 100644 --- a/es/overviews/parallel-collections/performance.md +++ b/_es/overviews/parallel-collections/performance.md @@ -1,12 +1,13 @@ --- -layout: overview-large +layout: multipage-overview title: Midiendo el rendimiento -disqus: true +discourse: false partof: parallel-collections +overview-name: Parallel Collections + num: 8 -outof: 8 language: es --- @@ -14,50 +15,50 @@ language: es Algunas veces el modelo de rendimiento de la JVM se complica debido a comentarios sobre el mismo, y como resultado de los mismos, se tienen concepciones equívocas del mismo. -Por diferentes motivos, determinado código podría ofrecer un rendimiento o escalabilidad +Por diferentes motivos, determinado código podría ofrecer un rendimiento o escalabilidad inferior a la esperada. A continuación ofrecemos algunos ejemplos. Uno de los principales motivos es que el proceso de compilación de una aplicación que se ejecuta sobre la JVM no es el mismo que el de un lenguaje compilado de manera estática -(véase \[[2][2]\]). Los compiladores de Java y Scala traducen el código fuente en *bytecode* y -el conjunto de optimizaciones que llevan a cabo es muy reducido. En la mayoría de las JVM +(véase \[[2][2]\]). Los compiladores de Java y Scala traducen el código fuente en *bytecode* y +el conjunto de optimizaciones que llevan a cabo es muy reducido. En la mayoría de las JVM modernas, una vez el bytecode es ejecutado, se convierte en código máquina dependiente de la arquitectura de la máquina subyacente. Este proceso es conocido como compilación "just-int-time". -Sin embargo, el nivel de optimización del código es muy bajo puesto que dicho proceso deber ser +Sin embargo, el nivel de optimización del código es muy bajo puesto que dicho proceso deber ser lo más rápido posible. Con el objetivo de evitar el proceso de recompilación, el llamado compilador HotSpot optimiza únicamente aquellas partes del código que son ejecutadas de manera frecuente. Esto supone que los desarrolladores de "benchmarks" deberán ser conscientes que los -programas podrían presentar rendimientos dispares en diferentes ejecuciones. Múltiples ejecuciones +programas podrían presentar rendimientos dispares en diferentes ejecuciones. Múltiples ejecuciones de un mismo fragmento de código (por ejemplo un método) podrían ofrecer rendimientos dispares en función de si se ha llevado a cabo un proceso de optimización del código entre dichas ejecuciones. Adicionalmente, la medición de los tiempos de ejecución de un fragmento de código podría incluir el tiempo en el que el propio compilador JIT lleva a cabo el proceso de optimizacion, falseando los resultados. Otro elemento "oculto" que forma parte de la JVM es la gestión automática de la memoria. De vez en cuando, -la ejecución de un programa es detenida para que el recolector de basura entre en funcionamiento. Si el +la ejecución de un programa es detenida para que el recolector de basura entre en funcionamiento. Si el programa que estamos analizando realiza alguna reserva de memoria (algo que la mayoría de programas hacen), el recolector de basura podría entrar en acción, posiblemente distorsionando los resultados. Con el objetivo de disminuir los efectos de la recolección de basura, el programa bajo estudio deberá ser ejecutado en múltiples ocasiones para disparar numerosas recolecciones de basura. -Una causa muy común que afecta de manera notable al rendimiento son las conversiones implícitas que se +Una causa muy común que afecta de manera notable al rendimiento son las conversiones implícitas que se llevan a cabo cuando se pasa un tipo primitivo a un método que espera un argumento genérico. En tiempo de ejecución, los tipos primitivos con convertidos en los objetos que los representan, de manera que puedan ser pasados como argumentos en los métodos que presentan parámetros genéricos. Este proceso implica un conjunto extra de reservas de memoria y es más lento, ocasionando nueva basura en el heap. Cuando nos referimos al rendimiento en colecciones paralelas la contención de la memoria es un problema muy -común, dado que el desarrollador no dispone de un control explícito sobre la asignación de los objetos. +común, dado que el desarrollador no dispone de un control explícito sobre la asignación de los objetos. De hecho, debido a los efectos ocasionados por la recolección de basura, la contención puede producirse en un estado posterior del ciclo de vida de la aplicación, una vez los objetos hayan ido circulando por la memoria. Estos efectos deberán ser tenidos en cuenta en el momento en que se esté desarrollando un benchmark. ## Ejemplo de microbenchmarking -Numerosos enfoques permiten evitar los anteriores efectos durante el periodo de medición. -En primer lugar, el microbenchmark debe ser ejecutado el número de veces necesario que -permita asegurar que el compilador just-in-time ha compilado a código máquina y que -ha optimizado el código resultante. Esto es lo que comunmente se conoce como fase de +Numerosos enfoques permiten evitar los anteriores efectos durante el periodo de medición. +En primer lugar, el microbenchmark debe ser ejecutado el número de veces necesario que +permita asegurar que el compilador just-in-time ha compilado a código máquina y que +ha optimizado el código resultante. Esto es lo que comunmente se conoce como fase de calentamiento. El microbenchmark debe ser ejecutado en una instancia independiente de la máquina virtual @@ -72,20 +73,20 @@ Finalmente, con el objetivo de reducir la posibilidad de que una recolección de durante la ejecución del benchmark, idealmente, debería producirse un ciclo de recolección de basura antes de la ejecución del benchmark, retrasando el siguiente ciclo tanto como sea posible. -El trait `scala.testing.Benchmark` se predefine en la librería estándar de Scala y ha sido diseñado con +El trait `scala.testing.Benchmark` se predefine en la librería estándar de Scala y ha sido diseñado con el punto anterior en mente. A continuación se muestra un ejemplo del benchmarking de un operación map sobre un "trie" concurrente: import collection.parallel.mutable.ParTrieMap import collection.parallel.ForkJoinTaskSupport - + object Map extends testing.Benchmark { val length = sys.props("length").toInt val par = sys.props("par").toInt val partrie = ParTrieMap((0 until length) zip (0 until length): _*) - + partrie.tasksupport = new ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(par)) - + def run = { partrie map { kv => kv @@ -95,7 +96,7 @@ sobre un "trie" concurrente: El método `run` encapsula el código del microbenchmark que será ejecutado de manera repetitiva y cuyos tiempos de ejecución serán medidos. El anterior objeto `Map` extiende -el trait `scala.testing.Benchmark` y parsea los parámetros `par` (nivel de paralelismo) y +el trait `scala.testing.Benchmark` y parsea los parámetros `par` (nivel de paralelismo) y `length` (número de elementos en el trie). Ambos parámetros son especificados a través de propiedades del sistema. @@ -109,7 +110,7 @@ la librería de Scala. Los argumentos `-Dpar` y `-Dlength` representan el nivel el número de elementos respectivamente. Por último, `10` indica el número de veces que el benchmark debería ser ejecutado en una misma máquina virtual. -Los tiempos de ejecución obtenidos estableciendo `par` a los valores `1`, `2`, `4` y `8` sobre un +Los tiempos de ejecución obtenidos estableciendo `par` a los valores `1`, `2`, `4` y `8` sobre un procesador quad-core i7 con hyperthreading habilitado son los siguientes: Map$ 126 57 56 57 54 54 54 53 53 53 @@ -131,7 +132,7 @@ El tamaño de la colección a partir de la cual la paralelización merece la pen depende de numerosos factores. Algunos de ellos, aunque no todos, son: - Arquitectura de la máquina. Diferentes tipos de CPU ofrecen diferente características - de rendimiento y escalabilidad. Por ejemplo, si la máquina es multicore o presenta + de rendimiento y escalabilidad. Por ejemplo, si la máquina es multicore o presenta múltiples procesadores comunicados mediante la placa base. - Versión y proveedor de la JVM. Diferentes máquinas virtuales llevan a cabo @@ -158,7 +159,7 @@ depende de numerosos factores. Algunos de ellos, aunque no todos, son: producir contención. - Gestión de memoria. Cuando se reserva espacio para muchos objectos es posible - que se dispare un ciclo de recolección de basura. Dependiendo de cómo se + que se dispare un ciclo de recolección de basura. Dependiendo de cómo se distribuyan las referencias de los objetos el ciclo de recolección puede llevar más o menos tiempo. @@ -168,27 +169,27 @@ colección. Para ilustrar de manera aproximada cuál debería ser el valor de di a continuación, se presenta un ejemplo de una sencilla operación de reducción, __sum__ en este caso, libre de efectos colaterales sobre un vector en un procesador i7 quad-core (hyperthreading deshabilitado) sobre JDK7 - + import collection.parallel.immutable.ParVector - + object Reduce extends testing.Benchmark { val length = sys.props("length").toInt val par = sys.props("par").toInt val parvector = ParVector((0 until length): _*) - + parvector.tasksupport = new collection.parallel.ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(par)) - + def run = { parvector reduce { (a, b) => a + b } } } - + object ReduceSeq extends testing.Benchmark { val length = sys.props("length").toInt val vector = collection.immutable.Vector((0 until length): _*) - + def run = { vector reduce { (a, b) => a + b @@ -219,25 +220,25 @@ En un ejemplo diferente, utilizamos `mutable.ParHashMap` y el método `map` (un y ejecutamos el siguiente benchmark en el mismo entorno: import collection.parallel.mutable.ParHashMap - + object Map extends testing.Benchmark { val length = sys.props("length").toInt val par = sys.props("par").toInt val phm = ParHashMap((0 until length) zip (0 until length): _*) - + phm.tasksupport = new collection.parallel.ForkJoinTaskSupport(new scala.concurrent.forkjoin.ForkJoinPool(par)) - + def run = { phm map { kv => kv } } } - + object MapSeq extends testing.Benchmark { val length = sys.props("length").toInt val hm = collection.mutable.HashMap((0 until length) zip (0 until length): _*) - + def run = { hm map { kv => kv @@ -273,4 +274,4 @@ los que serían requeridos por arrays o vectores). 2. [Dynamic compilation and performance measurement, Brian Goetz][2] [1]: http://www.ibm.com/developerworks/java/library/j-jtp02225/index.html "flawed-benchmark" - [2]: http://www.ibm.com/developerworks/library/j-jtp12214/ "dynamic-compilation" \ No newline at end of file + [2]: http://www.ibm.com/developerworks/library/j-jtp12214/ "dynamic-compilation" diff --git a/es/tutorials/tour/_posts/2017-02-13-abstract-types.md b/_es/tour/abstract-types.md similarity index 96% rename from es/tutorials/tour/_posts/2017-02-13-abstract-types.md rename to _es/tour/abstract-types.md index a43a053457..ac54a11ca7 100644 --- a/es/tutorials/tour/_posts/2017-02-13-abstract-types.md +++ b/_es/tour/abstract-types.md @@ -1,40 +1,43 @@ --- -layout: tutorial +layout: tour title: Tipos Abstractos -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 2 -outof: 33 + language: es + +next-page: annotations +previous-page: tour-of-scala --- En Scala, las cases son parametrizadas con valores (los parámetros de construcción) y con tipos (si las clases son [genéricas](generic-classes.html)). Por razones de consistencia, no es posible tener solo valores como miembros de objetos; tanto los tipos como los valores son miembros de objetos. Además, ambos tipos de miembros pueden ser concretos y abstractos. A continuación un ejemplo el cual define de forma conjunta una asignación de valor tardía y un tipo abstracto como miembros del [trait](traits.html) `Buffer`. - + trait Buffer { type T val element: T } - + Los *tipos abstractos* son tipos los cuales su identidad no es precisamente conocida. En el ejemplo anterior, lo único que sabemos es que cada objeto de la clase `Buffer` tiene un miembro de tipo `T`, pero la definición de la clase `Buffer` no revela qué tipo concreto se corresponde con el tipo `T`. Tal como las definiciones de valores, es posible sobrescribir las definiciones de tipos en subclases. Esto permite revelar más información acerca de un tipo abstracto al acotar el tipo ligado (el cual describe las posibles instancias concretas del tipo abstracto). En el siguiente programa derivamos la clase `SeqBuffer` la cual nos permite almacenar solamente sequencias en el buffer al estipular que el tipo `T` tiene que ser un subtipo de `Seq[U]` para un nuevo tipo abstracto `U`: - + abstract class SeqBuffer extends Buffer { type U type T <: Seq[U] def length = element.length } - + Traits o [clases](classes.html) con miembros de tipos abstractos son generalmente usados en combinación con instancias de clases anónimas. Para ilustrar este concepto veremos un programa el cual trata con un buffer de sequencia que se remite a una lista de enteros. - + abstract class IntSeqBuffer extends SeqBuffer { type U = Int } - + object AbstractTypeTest1 extends App { def newIntSeqBuf(elem1: Int, elem2: Int): IntSeqBuffer = new IntSeqBuffer { @@ -45,11 +48,11 @@ Traits o [clases](classes.html) con miembros de tipos abstractos son generalment println("length = " + buf.length) println("content = " + buf.element) } - + El tipo retornado por el método `newIntSeqBuf` está ligado a la especialización del trait `Buffer` en el cual el tipo `U` es ahora equivalente a `Int`. Existe un tipo alias similar en la instancia de la clase anónima dentro del cuerpo del método `newIntSeqBuf`. En ese lugar se crea una nueva instancia de `IntSeqBuffer` en la cual el tipo `T` está ligado a `List[Int]`. Es necesario notar que generalmente es posible transformar un tipo abstracto en un tipo paramétrico de una clase y viceversa. A continuación se muestra una versión del código anterior el cual solo usa tipos paramétricos. - + abstract class Buffer[+T] { val element: T } @@ -65,5 +68,5 @@ Es necesario notar que generalmente es posible transformar un tipo abstracto en println("length = " + buf.length) println("content = " + buf.element) } - + Nótese que es necesario usar [variance annotations](variances.html) aquí; de otra manera no sería posible ocultar el tipo implementado por la secuencia concreta del objeto retornado por `newIntSeqBuf`. Además, existen casos en los cuales no es posible remplazar tipos abstractos con tipos parametrizados. diff --git a/es/tutorials/tour/_posts/2017-02-13-annotations.md b/_es/tour/annotations.md similarity index 98% rename from es/tutorials/tour/_posts/2017-02-13-annotations.md rename to _es/tour/annotations.md index d1c4805116..2f9dea008d 100644 --- a/es/tutorials/tour/_posts/2017-02-13-annotations.md +++ b/_es/tour/annotations.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Anotaciones -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 3 language: es + +next-page: classes +previous-page: abstract-types --- Las anotaciones sirven para asociar meta-información con definiciones. diff --git a/es/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md b/_es/tour/anonymous-function-syntax.md similarity index 88% rename from es/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md rename to _es/tour/anonymous-function-syntax.md index 629e1a5c43..9801b51b6a 100644 --- a/es/tutorials/tour/_posts/2017-02-13-anonymous-function-syntax.md +++ b/_es/tour/anonymous-function-syntax.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Sintaxis de funciones anónimas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 14 language: es + +next-page: currying +previous-page: nested-functions --- Scala provee una sintaxis relativamente livana para definir funciones anónimas. La siguiente expresión crea una función incrementadora para números enteros: @@ -24,7 +27,7 @@ También es posible definir funciones con múltiples parámetros: (x: Int, y: Int) => "(" + x + ", " + y + ")" -o sin parámetros: +o sin parámetros: () => { System.getProperty("user.dir") } diff --git a/es/tutorials/tour/_posts/2017-02-13-automatic-closures.md b/_es/tour/automatic-closures.md similarity index 96% rename from es/tutorials/tour/_posts/2017-02-13-automatic-closures.md rename to _es/tour/automatic-closures.md index b4ad92bf20..a04500bca2 100644 --- a/es/tutorials/tour/_posts/2017-02-13-automatic-closures.md +++ b/_es/tour/automatic-closures.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Construcción de closures automáticas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 16 language: es + +next-page: operators +previous-page: currying --- Scala permite pasar funciones sin parámetros como parámetros de un método. Cuando un método así es invocado, los parámetros reales de la función enviada sin parámetros no son evaluados y una función "nularia" (de aridad cero, 0-aria, o sin parámetros) es pasada en su lugar. Esta función encapsula el comportamiento del parámetro correspondiente (comunmente conocido como "llamada por nombre"). diff --git a/es/tutorials/tour/_posts/2017-02-13-case-classes.md b/_es/tour/case-classes.md similarity index 97% rename from es/tutorials/tour/_posts/2017-02-13-case-classes.md rename to _es/tour/case-classes.md index e881528ff7..4e4a203b20 100644 --- a/es/tutorials/tour/_posts/2017-02-13-case-classes.md +++ b/_es/tour/case-classes.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Clases Case -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 5 language: es + +next-page: compound-types +previous-page: classes --- Scala da soporte a la noción de _clases caso_ (en inglés _case classes_, desde ahora _clases Case_). Las clases Case son clases regulares las cuales exportan sus parámetros constructores y a su vez proveen una descomposición recursiva de sí mismas a través de [reconocimiento de patrones](pattern-matching.html). diff --git a/es/tutorials/tour/_posts/2017-02-13-classes.md b/_es/tour/classes.md similarity index 95% rename from es/tutorials/tour/_posts/2017-02-13-classes.md rename to _es/tour/classes.md index c1ac9490a3..1ed2c731dc 100644 --- a/es/tutorials/tour/_posts/2017-02-13-classes.md +++ b/_es/tour/classes.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Clases -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 4 language: es + +next-page: case-classes +previous-page: annotations --- En Scala, las clases son plantillas estáticas que pueden ser instanciadas por muchos objetos en tiempo de ejecución. Aquí se presenta una clase la cual define la clase `Point`: diff --git a/es/tutorials/tour/_posts/2017-02-13-compound-types.md b/_es/tour/compound-types.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-compound-types.md rename to _es/tour/compound-types.md index 19321db5e6..c9f43d3eee 100644 --- a/es/tutorials/tour/_posts/2017-02-13-compound-types.md +++ b/_es/tour/compound-types.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Tipos Compuestos -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 6 language: es + +next-page: sequence-comprehensions +previous-page: case-classes --- Algunas veces es necesario expresar que el tipo de un objeto es un subtipo de varios otros tipos. En Scala esto puede ser expresado con la ayuda de *tipos compuestos*, los cuales pueden entenderse como la intersección de otros tipos. diff --git a/es/tutorials/tour/_posts/2017-02-13-currying.md b/_es/tour/currying.md similarity index 92% rename from es/tutorials/tour/_posts/2017-02-13-currying.md rename to _es/tour/currying.md index 2e037d39d5..1e0fdac05e 100644 --- a/es/tutorials/tour/_posts/2017-02-13-currying.md +++ b/_es/tour/currying.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Currying -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 15 language: es + +next-page: automatic-closures +previous-page: anonymous-function-syntax --- _Nota de traducción: Currying es una técnica de programación funcional nombrada en honor al matemático y lógico Haskell Curry. Es por eso que no se intentará hacer ninguna traducción sobre el término Currying. Entiendase este como una acción, técnica base de PF. Como una nota al paso, el lenguaje de programación Haskell debe su nombre a este eximio matemático._ @@ -17,14 +20,14 @@ Los métodos pueden definir múltiples listas de parámetros. Cuando un método Aquí se muestra un ejemplo: object CurryTest extends App { - + def filter(xs: List[Int], p: Int => Boolean): List[Int] = if (xs.isEmpty) xs else if (p(xs.head)) xs.head :: filter(xs.tail, p) else filter(xs.tail, p) - + def modN(n: Int)(x: Int) = ((x % n) == 0) - + val nums = List(1, 2, 3, 4, 5, 6, 7, 8) println(filter(nums, modN(2))) println(filter(nums, modN(3))) diff --git a/es/tutorials/tour/_posts/2017-02-13-default-parameter-values.md b/_es/tour/default-parameter-values.md similarity index 95% rename from es/tutorials/tour/_posts/2017-02-13-default-parameter-values.md rename to _es/tour/default-parameter-values.md index 779362b6ad..eb4b70911d 100644 --- a/es/tutorials/tour/_posts/2017-02-13-default-parameter-values.md +++ b/_es/tour/default-parameter-values.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Valores de parámetros por defecto -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 34 language: es + +next-page: named-parameters +previous-page: implicit-conversions --- Scala tiene la capacidad de dar a los parámetros valores por defecto que pueden ser usados para permitir a quien invoca el método o función que omita dichos parámetros. diff --git a/es/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md b/_es/tour/explicitly-typed-self-references.md similarity index 97% rename from es/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md rename to _es/tour/explicitly-typed-self-references.md index 61d83230d3..ff8545c75b 100644 --- a/es/tutorials/tour/_posts/2017-02-13-explicitly-typed-self-references.md +++ b/_es/tour/explicitly-typed-self-references.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Autorefrencias explicitamente tipadas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 27 language: es + +next-page: local-type-inference +previous-page: lower-type-bounds --- Cuando se está construyendo software extensible, algunas veces resulta útil declarar el tipo de la variable `this` explícitamente. Para motivar esto, realizaremos una pequeña representación de una estructura de datos Grafo, en Scala. @@ -100,4 +103,3 @@ Aquí hay un ejemplo de uso de la clase `GrafoDirigidoConcreto`: n2.conectarCon(n3) n1.conectarCon(n3) } - diff --git a/es/tutorials/tour/_posts/2017-02-13-extractor-objects.md b/_es/tour/extractor-objects.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-extractor-objects.md rename to _es/tour/extractor-objects.md index 4700919da4..9278a2e276 100644 --- a/es/tutorials/tour/_posts/2017-02-13-extractor-objects.md +++ b/_es/tour/extractor-objects.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Objetos Extractores -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 8 language: es + +next-page: generic-classes +previous-page: sequence-comprehensions --- En Scala pueden ser definidos patrones independientemente de las clases Caso (en inglés case classes, desde ahora clases Case). Para este fin exite un método llamado `unapply` que proveera el ya dicho extractor. Por ejemplo, en el código siguiente se define el objeto extractor `Twice` @@ -16,7 +19,7 @@ En Scala pueden ser definidos patrones independientemente de las clases Caso (en def apply(x: Int): Int = x * 2 def unapply(z: Int): Option[Int] = if (z%2 == 0) Some(z/2) else None } - + object TwiceTest extends App { val x = Twice(21) x match { case Twice(n) => Console.println(n) } // imprime 21 diff --git a/es/tutorials/tour/_posts/2017-02-13-generic-classes.md b/_es/tour/generic-classes.md similarity index 93% rename from es/tutorials/tour/_posts/2017-02-13-generic-classes.md rename to _es/tour/generic-classes.md index 5174c68727..949baba87c 100644 --- a/es/tutorials/tour/_posts/2017-02-13-generic-classes.md +++ b/_es/tour/generic-classes.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Clases genéricas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 9 language: es + +next-page: implicit-parameters +previous-page: extractor-objects --- Tal como en Java 5 ([JDK 1.5](http://java.sun.com/j2se/1.5/)), Scala provee soporte nativo para clases parametrizados con tipos. Eso es llamado clases genéricas y son especialmente importantes para el desarrollo de clases tipo colección. diff --git a/es/tutorials/tour/_posts/2017-02-13-higher-order-functions.md b/_es/tour/higher-order-functions.md similarity index 92% rename from es/tutorials/tour/_posts/2017-02-13-higher-order-functions.md rename to _es/tour/higher-order-functions.md index 4b2695b25d..899dca2139 100644 --- a/es/tutorials/tour/_posts/2017-02-13-higher-order-functions.md +++ b/_es/tour/higher-order-functions.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Funciones de orden superior -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 18 language: es + +next-page: pattern-matching +previous-page: operators --- Scala permite la definición de funciones de orden superior. Estas funciones son las que _toman otras funciones como parámetros_, o las cuales _el resultado es una función_. Aquí mostramos una función `apply` la cual toma otra función `f` y un valor `v` como parámetros y aplica la función `f` a `v`: @@ -17,17 +20,17 @@ Scala permite la definición de funciones de orden superior. Estas funciones son _Nota: los métodos son automáticamente tomados como funciones si el contexto lo requiere._ Otro ejemplo: - + class Decorator(left: String, right: String) { def layout[A](x: A) = left + x.toString() + right } - + object FunTest extends App { def apply(f: Int => String, v: Int) = f(v) val decorator = new Decorator("[", "]") println(apply(decorator.layout, 7)) } - + La ejecución da como valor el siguiente resultado: [7] diff --git a/_es/tour/implicit-conversions.md b/_es/tour/implicit-conversions.md new file mode 100644 index 0000000000..1979510108 --- /dev/null +++ b/_es/tour/implicit-conversions.md @@ -0,0 +1,16 @@ +--- +layout: tour +title: Implicit Conversions + +discourse: false + +partof: scala-tour + +num: 32 +language: es + +next-page: default-parameter-values +previous-page: variances +--- + +(this page has not been translated into Spanish) diff --git a/es/tutorials/tour/_posts/2017-02-13-implicit-parameters.md b/_es/tour/implicit-parameters.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-implicit-parameters.md rename to _es/tour/implicit-parameters.md index bc609cf03c..581593a7c3 100644 --- a/es/tutorials/tour/_posts/2017-02-13-implicit-parameters.md +++ b/_es/tour/implicit-parameters.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Parámetros implícitos -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 10 language: es + +next-page: inner-classes +previous-page: generic-classes --- Un método con _parámetros implícitos_ puede ser aplicado a argumentos tal como un método normal. En este caso la etiqueta `implicit` no tiene efecto. De todas maneras, si a un método le faltan argumentos para sus parámetros implícitos, tales argumentos serán automáticamente provistos. @@ -17,7 +20,7 @@ Los argumentos reales que son elegibles para ser pasados a un parámetro implíc * Segunda, además son elegibles todos los miembros de modulos `companion` (ver [objetos companion] (singleton-objects.html) ) del tipo de parámetro implicito que tienen la etiqueta `implicit`. En el siguiente ejemplo definimos un método `sum` el cual computa la suma de una lista de elementos usando las operaciones `add` y `unit` de `Monoid`. Note que los valores implícitos no pueden ser de nivel superior (top-level), deben ser miembros de una plantilla. - + abstract class SemiGroup[A] { def add(x: A, y: A): A } diff --git a/es/tutorials/tour/_posts/2017-02-13-inner-classes.md b/_es/tour/inner-classes.md similarity index 96% rename from es/tutorials/tour/_posts/2017-02-13-inner-classes.md rename to _es/tour/inner-classes.md index d4282f64e4..c072021dc8 100644 --- a/es/tutorials/tour/_posts/2017-02-13-inner-classes.md +++ b/_es/tour/inner-classes.md @@ -1,17 +1,20 @@ --- -layout: tutorial +layout: tour title: Clases Internas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 11 language: es + +next-page: mixin-class-composition +previous-page: implicit-parameters --- En Scala es posible que las clases tengan como miembro otras clases. A diferencia de lenguajes similares a Java donde ese tipo de clases internas son miembros de las clases que las envuelven, en Scala esas clases internas están ligadas al objeto externo. Para ilustrar esta diferencia, vamos a mostrar rápidamente una implementación del tipo grafo: - + class Graph { class Node { var connectedNodes: List[Node] = Nil @@ -39,9 +42,9 @@ En nuestro programa, los grafos son representados mediante una lista de nodos. E n1.connectTo(n2) n3.connectTo(n1) } - + Ahora vamos a completar el ejemplo con información relacionada al tipado para definir explicitamente de qué tipo son las entidades anteriormente definidas: - + object GraphTest extends App { val g: Graph = new Graph val n1: g.Node = g.newNode @@ -54,7 +57,7 @@ Ahora vamos a completar el ejemplo con información relacionada al tipado para d El código anterior muestra que al tipo del nodo le es prefijado con la instancia superior (que en nuestro ejemplo es `g`). Si ahora tenemos dos grafos, el sistema de tipado de Scala no nos permite mezclar nodos definidos en un grafo con nodos definidos en otro, ya que los nodos del otro grafo tienen un tipo diferente. Aquí está el programa ilegal: - + object IllegalGraphTest extends App { val g: Graph = new Graph val n1: g.Node = g.newNode @@ -64,9 +67,9 @@ Aquí está el programa ilegal: val n3: h.Node = h.newNode n1.connectTo(n3) // ilegal! } - + Por favor note que en Java la última linea del ejemplo anterior hubiese sido correcta. Para los nodos de ambos grafos, Java asignaría el mismo tipo `Graph.Node`; es decir, `Node` es prefijado con la clase `Graph`. En Scala un tipo similar también puede ser definido, pero es escrito `Graph#Node`. Si queremos que sea posible conectar nodos de distintos grafos, es necesario modificar la implementación inicial del grafo de la siguiente manera: - + class Graph { class Node { var connectedNodes: List[Graph#Node] = Nil // Graph#Node en lugar de Node diff --git a/es/tutorials/tour/_posts/2017-02-13-local-type-inference.md b/_es/tour/local-type-inference.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-local-type-inference.md rename to _es/tour/local-type-inference.md index 3fa3c0d41b..b236ca118a 100644 --- a/es/tutorials/tour/_posts/2017-02-13-local-type-inference.md +++ b/_es/tour/local-type-inference.md @@ -1,16 +1,19 @@ --- -layout: tutorial +layout: tour title: Inferencia de tipos Local -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 29 language: es + +next-page: unified-types +previous-page: explicitly-typed-self-references --- -Scala tiene incorporado un mecanismo de inferencia de tipos el cual permite al programador omitir ciertos tipos de anotaciones. Por ejemplo, generalmente no es necesario especificar el tipo de una variable, ya que el compilador puede deducir el tipo mediante la expresión de inicialización de la variable. También puede generalmente omitirse los tipos de retorno de métodos ya que se corresponden con el tipo del cuerpo, que es inferido por el compilador. +Scala tiene incorporado un mecanismo de inferencia de tipos el cual permite al programador omitir ciertos tipos de anotaciones. Por ejemplo, generalmente no es necesario especificar el tipo de una variable, ya que el compilador puede deducir el tipo mediante la expresión de inicialización de la variable. También puede generalmente omitirse los tipos de retorno de métodos ya que se corresponden con el tipo del cuerpo, que es inferido por el compilador. Aquí hay un ejemplo: @@ -19,7 +22,7 @@ Aquí hay un ejemplo: val y = x.toString() // el tipo de y es String def succ(x: Int) = x + 1 // el método succ retorna valores Int } - + Para métodos recursivos, el compilador no es capaz de inferir el tipo resultado. A continuación mostramos un programa el cual falla por esa razón: object InferenceTest2 { diff --git a/es/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md b/_es/tour/lower-type-bounds.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md rename to _es/tour/lower-type-bounds.md index d7d1a0d082..0819ecde6f 100644 --- a/es/tutorials/tour/_posts/2017-02-13-lower-type-bounds.md +++ b/_es/tour/lower-type-bounds.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Límite de tipado inferior -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 26 language: es + +next-page: explicitly-typed-self-references +previous-page: upper-type-bounds --- Mientras que los [límites de tipado superior](upper-type-bounds.html) limitan el tipo de un subtipo de otro tipo, los *límites de tipado inferior* declaran que un tipo sea un supertipo de otro tipo. El término `T >: A` expresa que el parámetro de tipo `T` o el tipo abstracto `T` se refiera a un supertipo del tipo `A` @@ -46,4 +49,3 @@ Este código ilustra el concepto: .prepend("world") val anyList: ListNode[Any] = strList.prepend(12345) } - diff --git a/es/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md b/_es/tour/mixin-class-composition.md similarity index 88% rename from es/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md rename to _es/tour/mixin-class-composition.md index 68d0212d51..6343e0a7c6 100644 --- a/es/tutorials/tour/_posts/2017-02-13-mixin-class-composition.md +++ b/_es/tour/mixin-class-composition.md @@ -1,47 +1,50 @@ --- -layout: tutorial +layout: tour title: Composición de clases mixin -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 12 language: es + +next-page: singleton-objects +previous-page: inner-classes --- _Nota de traducción: La palabra `mixin` puede ser traducida como mezcla, dando título a esta sección de: Composición de clases Mezcla, pero es preferible utilizar la notación original_ A diferencia de lenguajes que solo soportan _herencia simple_, Scala tiene una notación más general de la reutilización de clases. Scala hace posible reutilizar la _nueva definición de miembros de una clase_ (es decir, el delta en relación a la superclase) en la definición de una nueva clase. Esto es expresado como una _composición de clases mixin_. Considere la siguiente abstracción para iteradores. - + abstract class AbsIterator { type T def hasNext: Boolean - def next: T + def next(): T } - + A continuación, considere una clase mezcla la cual extiende `AbsIterator` con un método `foreach` el cual aplica una función dada a cada elemento retornado por el iterador. Para definir una clase que puede usarse como una clase mezcla usamos la palabra clave `trait`. - + trait RichIterator extends AbsIterator { - def foreach(f: T => Unit) { while (hasNext) f(next) } + def foreach(f: T => Unit) { while (hasNext) f(next()) } } - + Aquí se muestra una clase iterador concreta, la cual retorna caracteres sucesivos de una cadena de caracteres dada: - + class StringIterator(s: String) extends AbsIterator { type T = Char private var i = 0 def hasNext = i < s.length() - def next = { val ch = s charAt i; i += 1; ch } + def next() = { val ch = s charAt i; i += 1; ch } } - + Nos gustaría combinar la funcionalidad de `StringIterator` y `RichIterator` en una sola clase. Solo con herencia simple e interfaces esto es imposible, ya que ambas clases contienen implementaciones para sus miembros. Scala nos ayuda con sus _compisiciones de clases mezcladas_. Permite a los programadores reutilizar el delta de la definición de una clase, esto es, todas las nuevas definiciones que no son heredadas. Este mecanismo hace posible combinar `StringIterator` con `RichIterator`, como es hecho en el siguiente programa, el cual imprime una columna de todos los caracteres de una cadena de caracteres dada. - + object StringIteratorTest { def main(args: Array[String]) { - class Iter extends StringIterator(args(0)) with RichIterator + class Iter extends StringIterator("Scala") with RichIterator val iter = new Iter iter foreach println } } - + La clase `Iter` en la función `main` es construida de una composición mixin de los padres `StringIterator` y `RichIterator` con la palabra clave `with`. El primera padre es llamado la _superclase_ de `Iter`, mientras el segundo padre (y cualquier otro que exista) es llamada un _mixin_. diff --git a/es/tutorials/tour/_posts/2017-02-13-named-parameters.md b/_es/tour/named-parameters.md similarity index 93% rename from es/tutorials/tour/_posts/2017-02-13-named-parameters.md rename to _es/tour/named-parameters.md index 166c7c049e..6ecb8c877d 100644 --- a/es/tutorials/tour/_posts/2017-02-13-named-parameters.md +++ b/_es/tour/named-parameters.md @@ -1,13 +1,15 @@ --- -layout: tutorial +layout: tour title: Parámetros nombrados -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 35 language: es + +previous-page: default-parameter-values --- En la invocación de métodos y funciones se puede usar el nombre de las variables explícitamente en la llamada, de la siguiente manera: diff --git a/es/tutorials/tour/_posts/2017-02-13-nested-functions.md b/_es/tour/nested-functions.md similarity index 86% rename from es/tutorials/tour/_posts/2017-02-13-nested-functions.md rename to _es/tour/nested-functions.md index 7d17af9114..c592b30c65 100644 --- a/es/tutorials/tour/_posts/2017-02-13-nested-functions.md +++ b/_es/tour/nested-functions.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Funciones Anidadas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 13 language: es + +next-page: anonymous-function-syntax +previous-page: singleton-objects --- En scala es posible anidar definiciones de funciones. El siguiente objeto provee una función `filter` para extraer valores de una lista de enteros que están por debajo de un valor determinado: diff --git a/es/tutorials/tour/_posts/2017-02-13-operators.md b/_es/tour/operators.md similarity index 91% rename from es/tutorials/tour/_posts/2017-02-13-operators.md rename to _es/tour/operators.md index 627a7e2045..fa7c55cf65 100644 --- a/es/tutorials/tour/_posts/2017-02-13-operators.md +++ b/_es/tour/operators.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Operadores -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 17 language: es + +next-page: higher-order-functions +previous-page: automatic-closures --- En Scala, cualquier método el cual reciba un solo parámetro puede ser usado como un *operador de infijo (infix)*. Aquí se muestra la definición de la clase `MyBool`, la cual define tres métodos `and`, `or`, y `negate`. diff --git a/es/tutorials/tour/_posts/2017-02-13-pattern-matching.md b/_es/tour/pattern-matching.md similarity index 94% rename from es/tutorials/tour/_posts/2017-02-13-pattern-matching.md rename to _es/tour/pattern-matching.md index 1951c93ae8..d20d83bf56 100644 --- a/es/tutorials/tour/_posts/2017-02-13-pattern-matching.md +++ b/_es/tour/pattern-matching.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Reconocimiento de patrones -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 20 language: es + +next-page: polymorphic-methods +previous-page: higher-order-functions --- _Nota de traducción: Es dificil encontrar en nuestro idioma una palabra que se relacione directamente con el significado de `match` en inglés. Podemos entender a `match` como "coincidir" o "concordar" con algo. En algunos lugares se utiliza la palabra `machear`, aunque esta no existe en nuestro idioma con el sentido que se le da en este texto, sino que se utiliza como traducción de `match`._ diff --git a/es/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md b/_es/tour/polymorphic-methods.md similarity index 91% rename from es/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md rename to _es/tour/polymorphic-methods.md index 1963b76926..c14ca2a18d 100644 --- a/es/tutorials/tour/_posts/2017-02-13-polymorphic-methods.md +++ b/_es/tour/polymorphic-methods.md @@ -1,19 +1,22 @@ --- -layout: tutorial +layout: tour title: Métodos polimórficos -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 21 language: es + +next-page: regular-expression-patterns +previous-page: pattern-matching --- Los métodos en Scala pueden ser parametrizados tanto con valores como con tipos. Como a nivel de clase, parámetros de valores son encerrados en un par de paréntesis, mientras que los parámetros de tipo son declarados dentro de un par de corchetes. Aquí hay un ejemplo: - + object PolyTest extends App { def dup[T](x: T, n: Int): List[T] = if (n == 0) Nil diff --git a/es/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md b/_es/tour/regular-expression-patterns.md similarity index 95% rename from es/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md rename to _es/tour/regular-expression-patterns.md index 3b1cca249c..bb0571a27a 100644 --- a/es/tutorials/tour/_posts/2017-02-13-regular-expression-patterns.md +++ b/_es/tour/regular-expression-patterns.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Patrones basados en expresiones regulares -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 22 language: es + +next-page: traits +previous-page: polymorphic-methods --- ## Patrones de secuencias que ignoran a la derecha ## diff --git a/es/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md b/_es/tour/sequence-comprehensions.md similarity index 95% rename from es/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md rename to _es/tour/sequence-comprehensions.md index d6b0be38b7..203a01b4c8 100644 --- a/es/tutorials/tour/_posts/2017-02-13-sequence-comprehensions.md +++ b/_es/tour/sequence-comprehensions.md @@ -1,19 +1,22 @@ --- -layout: tutorial +layout: tour title: Sequencias por Comprensión -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 7 language: es + +next-page: extractor-objects +previous-page: compound-types --- Scala cuenta con una notación ligera para expresar *sequencias por comprensión* (*sequence comprehensions*). Las comprensiones tienen la forma `for (enumeradores) yield e`, donde `enumeradores` se refiere a una lista de enumeradores separados por el símbolo punto y coma (;). Un *enumerador* puede ser tanto un generador el cual introduce nuevas variables, o un filtro. La comprensión evalúa el cuerpo `e` por cada paso (o ciclo) generado por los enumeradores y retorna una secuencia de estos valores. Aquí hay un ejemplo: - + object ComprehensionTest1 extends App { def pares(desde: Int, hasta: Int): List[Int] = for (i <- List.range(desde, hasta) if i % 2 == 0) yield i @@ -26,7 +29,7 @@ El programa produce los siguientes valores List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18) -Aquí se muestra un ejemplo más complicado que computa todos los pares de números entre `0` y `n-1` cuya suma es igual a un número dado `v`: +Aquí se muestra un ejemplo más complicado que computa todos los pares de números entre `0` y `n-1` cuya suma es igual a un número dado `v`: object ComprehensionTest2 extends App { def foo(n: Int, v: Int) = @@ -49,10 +52,9 @@ Esta es la salida del programa: (16, 16) Existe también una forma especial de comprensión de secuencias la cual retorna `Unit`. En este caso las variables que son creadas por la lista de generadores y filtros son usados para realizar tareas con efectos colaterales (modificaciones de algún tipo). El programador tiene que omitir la palabra reservada `yield` para usar una comprensión de este tipo. - + object ComprehensionTest3 extends App { for (i <- Iterator.range(0, 20); j <- Iterator.range(i, 20) if i + j == 32) println("(" + i + ", " + j + ")") } - diff --git a/es/tutorials/tour/_posts/2017-02-13-singleton-objects.md b/_es/tour/singleton-objects.md similarity index 89% rename from es/tutorials/tour/_posts/2017-02-13-singleton-objects.md rename to _es/tour/singleton-objects.md index b185924d29..021b413912 100644 --- a/es/tutorials/tour/_posts/2017-02-13-singleton-objects.md +++ b/_es/tour/singleton-objects.md @@ -1,15 +1,16 @@ --- -layout: tutorial +layout: tour title: Singleton Objects -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 12 language: es -next-page: xml-processing -previous-page: pattern-matching + +next-page: nested-functions +previous-page: mixin-class-composition --- Métodos y valores que no están asociados con instancias individuales de una [clase](classes.html) se denominan *objetos singleton* y se denotan con la palabra reservada `object` en vez de `class`. @@ -30,7 +31,7 @@ Un objeto singleton puede extender clases y _traits_. De hecho, una [clase Case] La mayoría de los objetos singleton no están solos, sino que en realidad están asociados con clases del mismo nombre. El "objeto singleton del mismo nombre" de una case Case, mencionada anteriormente es un ejemplo de esto. Cuando esto sucede, el objeto singleton es llamado el *objeto acompañante* de la clase, y la clase es a su vez llamada la *clase acompañante* del objeto. -[Scaladoc](https://wiki.scala-lang.org/display/SW/Introduction) proporciona un soporte especial para ir y venir entre una clase y su acompañante: Si el gran círculo conteniendo la “C” u la “O” tiene su borde inferior doblado hacia adentro, es posible hacer click en el círculo para ir a su acompañante. +[Scaladoc](/style/scaladoc.html) proporciona un soporte especial para ir y venir entre una clase y su acompañante: Si el gran círculo conteniendo la “C” u la “O” tiene su borde inferior doblado hacia adentro, es posible hacer click en el círculo para ir a su acompañante. Una clase y su objeto acompañante, si existe, deben estar definidos en el mismo archivo fuente. Como por ejemplo: diff --git a/es/tutorials/tour/_posts/2017-02-13-tour-of-scala.md b/_es/tour/tour-of-scala.md similarity index 98% rename from es/tutorials/tour/_posts/2017-02-13-tour-of-scala.md rename to _es/tour/tour-of-scala.md index 3c5fdc892e..ba2fe0eeaf 100644 --- a/es/tutorials/tour/_posts/2017-02-13-tour-of-scala.md +++ b/_es/tour/tour-of-scala.md @@ -1,13 +1,15 @@ --- -layout: tutorial +layout: tour title: Introducción -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 1 language: es + +next-page: abstract-types --- Scala es un lenguaje de programación moderno multi-paradigma diseñado para expresar patrones de programación comunes de una forma concisa, elegante, y de tipado seguro. Integra fácilmente características de lenguajes orientados a objetos y funcionales. diff --git a/es/tutorials/tour/_posts/2017-02-13-traits.md b/_es/tour/traits.md similarity index 92% rename from es/tutorials/tour/_posts/2017-02-13-traits.md rename to _es/tour/traits.md index b06a767fea..363fee8148 100644 --- a/es/tutorials/tour/_posts/2017-02-13-traits.md +++ b/_es/tour/traits.md @@ -1,27 +1,30 @@ --- -layout: tutorial +layout: tour title: Traits -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 24 language: es + +next-page: upper-type-bounds +previous-page: regular-expression-patterns --- _Nota de traducción: La palabra `trait` en inglés puede traducirse literalmente como `rasgo` o `caracteristica`. Preferimos la designación original trait por ser una característica muy natural de Scala._ -De forma similar a las interfaces de Java, los traits son usados para definir tipos de objetos al especificar el comportamiento mediante los métodos provistos. A diferencia de Java, Scala permite a los traits ser parcialmente implementados, esto es, es posible definir implementaciones por defecto para algunos métodos. En contraste con las clases, los traits no pueden tener parámetros de constructor. +De forma similar a las interfaces de Java, los traits son usados para definir tipos de objetos al especificar el comportamiento mediante los métodos provistos. A diferencia de Java, Scala permite a los traits ser parcialmente implementados, esto es, es posible definir implementaciones por defecto para algunos métodos. En contraste con las clases, los traits no pueden tener parámetros de constructor. A continuación se muestra un ejemplo: - + trait Similarity { def isSimilar(x: Any): Boolean def isNotSimilar(x: Any): Boolean = !isSimilar(x) } - + Este trait consiste de dos métodos `isSimilar` y `isNotSimilar`. Mientras `isSimilar` no provee una implementación concreta del método (es abstracto en la terminología Java), el método `isNotSimilar` define una implementación concreta. Consecuentemente, las clases que integren este trait solo tienen que proveer una implementación concreta para `isSimilar`. El comportamiento de `isNotSimilar` es directamente heredado del trait. Los traits típicamente son integrados a una clase (u otros traits) mediante una [Composición de clases mixin](mixin-class-composition.html): - + class Point(xc: Int, yc: Int) extends Similarity { var x: Int = xc var y: Int = yc @@ -37,7 +40,7 @@ Este trait consiste de dos métodos `isSimilar` y `isNotSimilar`. Mientras `isSi println(p1.isNotSimilar(p3)) println(p1.isNotSimilar(2)) } - + Esta es la salida del programa: false diff --git a/es/tutorials/tour/_posts/2017-02-13-unified-types.md b/_es/tour/unified-types.md similarity index 96% rename from es/tutorials/tour/_posts/2017-02-13-unified-types.md rename to _es/tour/unified-types.md index cc34e91b9f..3bdc3541af 100644 --- a/es/tutorials/tour/_posts/2017-02-13-unified-types.md +++ b/_es/tour/unified-types.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Tipos Unificados -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 30 language: es + +next-page: variances +previous-page: local-type-inference --- A diferencia de Java, todos los valores en Scala son objetos (incluyendo valores numéricos y funciones). Dado que Scala está basado en clases, todos los valores son instancias de una clase. El diagrama siguiente ilustra esta jerarquía de clases: diff --git a/es/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md b/_es/tour/upper-type-bounds.md similarity index 93% rename from es/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md rename to _es/tour/upper-type-bounds.md index 5de06ada43..84124c8944 100644 --- a/es/tutorials/tour/_posts/2017-02-13-upper-type-bounds.md +++ b/_es/tour/upper-type-bounds.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Límite de tipado superior -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 25 language: es + +next-page: lower-type-bounds +previous-page: traits --- En Scala, los [parámetros de tipo](generic-classes.html) y los [tipos abstractos](abstract-types.html) pueden ser restringidos por un límite de tipado. Tales límites de tipado limitan los valores concretos de las variables de tipo y posiblemente revelan más información acerca de los miembros de tales tipos. Un _límite de tipado superior_ `T <: A` declara que la variable de tipo `T` es un subtipo del tipo `A`. @@ -29,6 +32,6 @@ Aquí se muestra un ejemplo el cual se basa en un límite de tipado superior par val list: List[MyInt] = List(MyInt(1), MyInt(2), MyInt(3)) println(findSimilar[MyInt](MyInt(4), list)) println(findSimilar[MyInt](MyInt(2), list)) - } + } Sin la anotación del límite de tipado superior no sería posible llamar al método `isSimilar` en el método `findSimilar`. El uso de los límites de tipado inferiores se discute [aquí](lower-type-bounds.html). diff --git a/es/tutorials/tour/_posts/2017-02-13-variances.md b/_es/tour/variances.md similarity index 96% rename from es/tutorials/tour/_posts/2017-02-13-variances.md rename to _es/tour/variances.md index dc783c6b15..ad4a8fc3c2 100644 --- a/es/tutorials/tour/_posts/2017-02-13-variances.md +++ b/_es/tour/variances.md @@ -1,13 +1,16 @@ --- -layout: tutorial +layout: tour title: Varianzas -disqus: true +discourse: false + +partof: scala-tour -tutorial: scala-tour -categories: tour num: 31 language: es + +next-page: implicit-conversions +previous-page: unified-types --- Scala soporta anotaciones de varianza para parámetros de tipo para [clases genéricas](generic-classes.html). A diferencia de Java 5 ([JDK 1.5](http://java.sun.com/j2se/1.5/)), las anotaciones de varianza pueden ser agregadas cuando una abstracción de clase es definidia, mientras que en Java 5, las anotaciones de varianza son dadas por los clientes cuando una albstracción de clase es usada. diff --git a/es/tutorials/scala-for-java-programmers.md b/_es/tutorials/scala-for-java-programmers.md similarity index 99% rename from es/tutorials/scala-for-java-programmers.md rename to _es/tutorials/scala-for-java-programmers.md index 9bd40852d1..71a7ba6023 100644 --- a/es/tutorials/scala-for-java-programmers.md +++ b/_es/tutorials/scala-for-java-programmers.md @@ -1,13 +1,14 @@ --- -layout: overview +layout: singlepage-overview title: Tutorial de Scala para programadores Java -overview: scala-for-java-programmers -disqus: true +partof: scala-for-java-programmers + +discourse: true language: es --- -Por Michel Schinz y Philipp Haller. +Por Michel Schinz y Philipp Haller. Traducción y arreglos Santiago Basulto. ## Introducción @@ -75,7 +76,7 @@ La declaración `import` en la tercer línea por lo tanto importa todos los miem Dentro del método `main` primero creamos una instancia de la clase `Date` la cual por defecto contiene la fecha actual. A continuación definimos un formateador de fechas utilizando el método estático `getDateInstance` que importamos previamente. Finalmente, imprimimos la fecha actual formateada de acuerdo a la instancia de `DateFormat` que fue "localizada". Esta última línea muestra una propiedad interesante de la sintaxis de Scala. Los métodos que toman un solo argumento pueden ser usados con una sintaxis de infijo Es decir, la expresión df format ahora - + es solamente otra manera más corta de escribir la expresión: df.format(ahora) @@ -129,7 +130,7 @@ En el siguiente programa, la función del temporizador se llama `unaVezPorSegund unaVezPorSegundo(tiempoVuela) } } - + _Nota: si nunca tuviste experiencias previas con programación funcional te recomiendo que te tomes unos segundos para analizar cuando se utilizan paréntesis y cuando no en los lugares donde aparece *callback*. Por ejemplo, dentro de la declaración de `unaVezPorSegundo` no aparece, ya que se trata de la función como un "valor", a diferencia de cómo aparece dentro del método, ya que en ese caso se la está invocando (por eso los paréntesis)._ Note that in order to print the string, we used the predefined method `println` instead of using the one from `System.out`. @@ -163,7 +164,7 @@ Como hemos visto anteriormente, Scala es un lenguaje orientado a objetos, y como Esta clase compleja toma dos argumentos, que son las partes real e imaginarias de un número complejo. Estos argumentos deben ser pasados cuando se crea una instancia de la clase `Complejo`, de la siguiente manera: new Complejo(1.5, 2.3) - + La clase contiene dos métodos llamados `re` e `im`, que proveen acceso a las dos partes del número. Debe notarse que el tipo de retorno de estos dos métodos no está expresado explícitamente. Será inferido automáticamente por el compilador, que primero mira la parte derecha de estos métodos y puede deducir que ambos retornan un valor de tipo `Double`. @@ -198,7 +199,7 @@ Es posible sobreescribir métodos heredados de una superclase en Scala. Aunque e class Complejo(real: Double, imaginaria: Double) { def re = real def im = imaginaria - override def toString() = + override def toString() = "" + re + (if (im < 0) "" else "+") + im + "i" } @@ -224,11 +225,11 @@ El hecho de que las clases `Sum`, `Var` y `Const` sean declaradas como clases ca en lugar de `new Const(5)`), - se crea automáticamente un "getter" (un método para obtener el valor) para los parámetros utilizados en el constructor (por ejemplo es posible - obtener el valor de `v` de una instancia `c` de la clase `Const` de la + obtener el valor de `v` de una instancia `c` de la clase `Const` de la siguiente manera: `c.v`), - se proveen definiciones por defecto de los métodos `equals` y `hashCode`, que trabajan sobre la estructura de las instancias y no sobre su identidad, -- se crea una definición por defecto del método `toString` que +- se crea una definición por defecto del método `toString` que imprime el valor de una forma "tipo código) (ej: la expresión del árbol `x+1` se imprimiría `Sum(Var(x),Const(1))`), - las instancias de estas clases pueden ser descompuestas @@ -377,7 +378,7 @@ La última característica de Scala que exploraremos en este tutorial es la de l Los tipos genéricos proveen al programador la habilidad de escribir código parametrizado por tipos. Por ejemplo, escribir una librería para listas enlazadas se enfrenta al problema de decidir qué tipo darle a los elementos de la lista. Ya que esta lista está pensada para ser usada en diferentes contextos, no es posible decidir que el tipo de elementos sea, digamos, `Int`. Esto sería completamente arbitrario y muy restrictivo. -Los programadores Java cuentan como último recurso con `Object`, que es el supertipo de todos los objetos. Esta solución de todas maneras está lejos de ser ideal, ya que no funciona con tipos primitivos (`int`, `long`, `float`, etc.) e implica que el programador tenga que realizar muchos casteos de tipos en su programa. +Los programadores Java cuentan como último recurso con `Object`, que es el supertipo de todos los objetos. Esta solución de todas maneras está lejos de ser ideal, ya que no funciona con tipos primitivos (`int`, `long`, `float`, etc.) e implica que el programador tenga que realizar muchos casteos de tipos en su programa. Scala hace posible definir clases genéricas (y métodos) para resolver este problema. Examinemos esto con un ejemplo del contenedor más simple posible: una referencia, que puede estar tanto vacía como apuntar a un objeto de algún tipo. diff --git a/fr/cheatsheets/index.md b/_fr/cheatsheets/index.md similarity index 97% rename from fr/cheatsheets/index.md rename to _fr/cheatsheets/index.md index d6a828a6d6..9cb47c6f8d 100644 --- a/fr/cheatsheets/index.md +++ b/_fr/cheatsheets/index.md @@ -1,16 +1,18 @@ --- layout: cheatsheet -istranslation: true title: Scalacheat + +partof: cheatsheet + by: Brendan O'Connor about: Grâce à Brendan O'Connor, ce memento vise à être un guide de référence rapide pour les constructions syntaxiques en Scala. Licencié par Brendan O'Connor sous licence CC-BY-SA 3.0. + language: fr --- ###### Contribué par {{ page.by }} +{{ page.about }} -| | | -| ------ | ------ | | variables | | | `var x = 5` | variable | | Good `val x = 5`
Bad `x=6` | constante | diff --git a/_includes/allsids.txt b/_includes/allsids.txt deleted file mode 100644 index dd33e8b365..0000000000 --- a/_includes/allsids.txt +++ /dev/null @@ -1,28 +0,0 @@ -

Pending SIPs

-
    - {% for post in site.categories.pending %} -
  • {{ post.title }} ( {{ post.date | date: "%b %Y" }} ) - {% if post.vote-status %} - {% if post.vote-status == 'accepted' %} - Accepted - {% elsif post.vote-status == 'deferred' %} - Deferred - {% elsif post.vote-status == 'postponed' %} - Postponed - {% elsif post.vote-status == 'under review' %} - Under Review - {% elsif post.vote-status == 'under revision' %} - Under Revision - {% elsif post.vote-status == 'numbered' %} - Numbered - {% elsif post.vote-status == 'dormant' %} - Dormant - {% elsif post.vote-status == 'not accepted' %} - Not Accepted - {% elsif post.vote-status == 'rejected' %} - Not Accepted - {% endif %} - {% endif %} -
  • - {% endfor %} -
diff --git a/_includes/blog-list.html b/_includes/blog-list.html new file mode 100644 index 0000000000..a82eeccc4e --- /dev/null +++ b/_includes/blog-list.html @@ -0,0 +1,75 @@ +{% comment %}Use the include variable 'category' to select the category to show (included in blog-categories.yml), or assign it to "all" if you want to show all posts.{% endcomment %} + +
+
+
+
+ +
+ {% for post in paginator.posts %} +
+

{{post.title}}

+

{{post.date | date: "%A %-d %B %Y"}}

+ {% if post.by %}

{{post.by}}

{% endif %} + {% if post.tags %} +
    + {% for tag in post.tags %} +
  • {{tag}}
  • + {% endfor %} +
+ {% endif %} +
+ {% endfor %} +
+
+ {% for category in site.data.blog-categories %} + {% if category.categoryId == include.category %} + {% assign currentCategoryPath = category.url %} + {% endif %} + {% endfor %} + + {% capture urlPath %}{% if include.category == "all" %}blog{% else %}{{currentCategoryPath}}{% endif %}{% endcapture %} + {% assign urlPath = urlPath | split: '/' | join: '/' | remove_first: '/' %} + {% include paginator.html urlPath=urlPath %} +
+ {% assign highlights = "" | split: "," %} + {% for post in site.posts %} + {% if post.isHighlight == true %} + {% assign highlights = highlights | push: post %} + {% endif %} + {% endfor %} + + {% for post in highlights %} + {% if forloop.first %} +
+
+
Highlights
+
+ {% endif %} +
+

{{post.title}}

+ {% if post.by %}

{{post.by}}

{% endif %} + {% if post.tags %} + {% for tag in post.tags %} +
    +
  • {{tag}}
  • +
+ {% endfor %} + {% endif %} +
+ {% if forloop.last %} +
+
+
+ {% endif %} + {% endfor %} + +
+
\ No newline at end of file diff --git a/_includes/books.html b/_includes/books.html new file mode 100644 index 0000000000..43c1645053 --- /dev/null +++ b/_includes/books.html @@ -0,0 +1,21 @@ + +
+ {% for book in site.books %} +
+ +
+

{{book.status}}

+

{{site.data.common.texts.booksBy}} {{book.authors | join: ", "}}

+

{{site.data.common.texts.booksPublishedBy}} {{book.publisher}}

+

{{book.content}}

+
+
+ {% endfor %} +
diff --git a/_includes/cheatsheet-header.txt b/_includes/cheatsheet-header.txt index 32965d410c..c4c9c3cc5b 100644 --- a/_includes/cheatsheet-header.txt +++ b/_includes/cheatsheet-header.txt @@ -2,33 +2,22 @@ - {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - + + - + - - - + + + - + - - - - + diff --git a/_includes/contributing-toc.txt b/_includes/contributing-toc.txt deleted file mode 100644 index 471940e7ec..0000000000 --- a/_includes/contributing-toc.txt +++ /dev/null @@ -1,7 +0,0 @@ -
-
-

Contents

-
- {% include thanks-to.txt %} -
-
diff --git a/_includes/contributions-projects-list.html b/_includes/contributions-projects-list.html new file mode 100644 index 0000000000..5a4c9bdbe7 --- /dev/null +++ b/_includes/contributions-projects-list.html @@ -0,0 +1,36 @@ +{% comment %} + Layouts using this include should pass an include variable called 'collection' referencing a collection carrying the data +{% endcomment %} +
+ {% for item in include.collection %} +
+ +
+

{{item.description}}

+
    + {% if item.homeLink %} +
  • Home
  • + {% if item.contributingLink or item.readmeLink or item.issuesLink %}
  • {% endif %} + {% endif %} + {% if item.issuesLink %} +
  • Issues
  • + {% if item.contributingLink or item.readmeLink %}
  • {% endif %} + {% endif %} + {% if item.readmeLink %} +
  • ReadMe
  • + {% if item.contributingLink %}
  • {% endif %} + {% endif %} + {% if item.contributingLink %} +
  • Contributing
  • + {% endif %} +
+
+
+ {% endfor %} + +
\ No newline at end of file diff --git a/_includes/coursera-stats-js.txt b/_includes/coursera-stats-js.txt deleted file mode 100644 index a65c30925b..0000000000 --- a/_includes/coursera-stats-js.txt +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/_includes/discourse.html b/_includes/discourse.html new file mode 100644 index 0000000000..1a08884791 --- /dev/null +++ b/_includes/discourse.html @@ -0,0 +1,12 @@ +
+ + diff --git a/_includes/disqus.txt b/_includes/disqus.txt deleted file mode 100644 index c4955c51e0..0000000000 --- a/_includes/disqus.txt +++ /dev/null @@ -1,18 +0,0 @@ -
- - -blog comments powered by Disqus diff --git a/_includes/download-resource-list.html b/_includes/download-resource-list.html new file mode 100644 index 0000000000..017af455af --- /dev/null +++ b/_includes/download-resource-list.html @@ -0,0 +1,31 @@ +

Other resources

+ +

You can find the installer download links for other operating systems, as well as documentation and source code archives for Scala {{page.release_version}} below.

+ +
+ + + + + {% unless page.dont_show_sizes %} + + {% endunless %} + + + +{% for resource in page.resources %} + + + + {% unless page.dont_show_sizes %} + + {% endunless %} + +{% endfor %} + +
ArchiveSystemSize
+ + {{ resource[1] }} + + {{ resource[3] }}{{ resource[4] }}
+
diff --git a/_includes/downloads-list.html b/_includes/downloads-list.html new file mode 100644 index 0000000000..f8a7554901 --- /dev/null +++ b/_includes/downloads-list.html @@ -0,0 +1,19 @@ +{% for top in (0..3) reversed %} + {% for major in (0..20) reversed %} + {% assign possibleVersionShort = top | append:'.' | append:major %} + {% assign sz = possibleVersionShort | size %} + {% if 3 == sz %} + {% assign possibleVersion = possibleVersionShort | append:'.' %} + {% else %} + {% assign possibleVersion = possibleVersionShort %} + {% endif %} + {% for page in site.downloads %} + {% assign releaseVersion = page.release_version | truncate:4, '' %} + {% if releaseVersion == possibleVersion %} + + {% endif %} + {% endfor %} + {% endfor %} +{% endfor %} \ No newline at end of file diff --git a/_includes/events-training-list-bottom.html b/_includes/events-training-list-bottom.html new file mode 100644 index 0000000000..f863e64506 --- /dev/null +++ b/_includes/events-training-list-bottom.html @@ -0,0 +1,12 @@ + + + {% if paginator.total_pages > 1 %} +
    + {% for page in (1..paginator.total_pages) %} +
  • + {{page}} +
  • + {% endfor %} +
+ {% endif %} + \ No newline at end of file diff --git a/_includes/events-training-list-top.html b/_includes/events-training-list-top.html new file mode 100644 index 0000000000..e3a7d0004c --- /dev/null +++ b/_includes/events-training-list-top.html @@ -0,0 +1,73 @@ +{% capture currentYear %}{{site.time | date: '%Y' | plus: 0}}{% endcapture %} + +
+
+
+ {% comment %}Because of Jekyll limitations, we need to pass the paginated collection to iterate in an include variable 'collection'{% endcomment %} + + {% capture firstMonth %}{{include.collection.first.date | date: "%m"}}{% endcapture %} + {% assign firstMonthNum = firstMonth | plus: 0 %} + {% capture lastMonth %}{{include.collection.last.date | date: "%m"}}{% endcapture %} + {% assign lastMonthNum = lastMonth | plus: 0 %} + + {% for m in (firstMonth..lastMonth) %} + {% assign currentMonthEvents = '' | split: ','' %} + + {% for event in include.collection %} + {% capture month %}{{event.date | date: "%m"}}{% endcapture %} + {% assign monthNum = month | plus: 0 %} + {% if monthNum == m %} + {% assign currentMonthEvents = currentMonthEvents | push: event %} + {% endif %} + {% endfor %} + + {% capture monthName %} + {% case m %} + {% when 1 %}January + {% when 2 %}February + {% when 3 %}March + {% when 4 %}April + {% when 5 %}May + {% when 6 %}June + {% when 7 %}July + {% when 8 %}August + {% when 9 %}September + {% when 10 %}October + {% when 11 %}November + {% when 12 %}December + {% endcase %} + {% endcapture %} + + {% for event in currentMonthEvents %} + {% capture year %}{{event.date | date: "%Y"}}{% endcapture %} + {% capture day %}{{event.date | date: "%d"}}{% endcapture %} + {% if forloop.first %} +

{{monthName}} {{year}}

+ + {% endif %} + {% endfor %} + {% endfor %} \ No newline at end of file diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 0000000000..5440bfc177 --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,97 @@ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% if page.layout == "sips"%} + +{% endif %} + + + diff --git a/_includes/footer.txt b/_includes/footer.txt deleted file mode 100644 index 65dfc817bc..0000000000 --- a/_includes/footer.txt +++ /dev/null @@ -1,15 +0,0 @@ -{% include footerbar.txt %} - - - - - - - - diff --git a/_includes/footerbar.txt b/_includes/footerbar.txt deleted file mode 100644 index 4eb47279d8..0000000000 --- a/_includes/footerbar.txt +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - diff --git a/_includes/frontpage-content.txt b/_includes/frontpage-content.txt deleted file mode 100644 index 4eda427647..0000000000 --- a/_includes/frontpage-content.txt +++ /dev/null @@ -1,97 +0,0 @@ -
- -

Community-driven documentation for Scala.

- -
    -
  • - Thumbnail -

    Overviews and Guides

    -

    Collections, Actors, Swing, and more.

    -

    Go there

    -
  • -
  • - Thumbnail -

    Tutorials

    -

    Coming from Java? Python? Ruby? Tutorials which help the transition from language XYZ to Scala.

    -

    Go there

    -
  • -
  • - Thumbnail -

    Glossary

    -

    Lost on some terminology? Check the glossary, direct from the book, Programming in Scala.

    -

    Go there

    -
  • -
-
- -
-
-
- -
- -

Available Documentation

- -

Scala Improvement Process Available

-

Read language improvement proposals, participate in discussions surrounding submitted proposals, or submit your own improvement proposal.

- -

Guides and Overviews Some Available

-

Some guides, such as Martin Odersky’s Collections Overview are now available.

- -

Tutorials Some Available

-

Some tutorials, such as the Scala for Java Programmers guide, are now available.

- -

Glossary Available

-

With permission from Artima Inc., we reproduce the glossary from Programming in Scala here, for easy reference.

- -

Cheatsheets Available

-

We've currently got one cheatsheet, thanks to Brendan O’Connor. Contributions in this area are welcome.

- -

Scala Style Guide Available

-

Thanks to Daniel Spiewak and David Copeland for putting together such an excellent style guide, and thanks to Simon Ochsenreither for converting it to Markdown.

- -

Language Specification Available

-

The official definition of Scala. For when you just have to know the truth.

- -

 

 

- -
-
-

Contributions Welcomed!

- This site was designed for core committers and the community alike to build documentation. We’d love help of any kind – from detailed articles or overviews of Scala’s language features, to help converting documents to Markdown. -

 

-

If you’d like to help, please see the Contribute section of the site, and feel free to contact Heather.

- -

Recent Comments

- - - - - - -
- -
-
-
diff --git a/_includes/frontpage-footer.txt b/_includes/frontpage-footer.txt deleted file mode 100644 index 5dd888b0d8..0000000000 --- a/_includes/frontpage-footer.txt +++ /dev/null @@ -1,6 +0,0 @@ - - {% include footerbar.txt %} - - - - diff --git a/_includes/frontpage-header.txt b/_includes/frontpage-header.txt deleted file mode 100644 index 9a41e3c5d5..0000000000 --- a/_includes/frontpage-header.txt +++ /dev/null @@ -1,153 +0,0 @@ - - - - - {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/gen-toc.txt b/_includes/gen-toc.txt deleted file mode 100644 index c5124cfd18..0000000000 --- a/_includes/gen-toc.txt +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

Contents

-
-
-
diff --git a/_includes/glossary-header.txt b/_includes/glossary-header.html similarity index 84% rename from _includes/glossary-header.txt rename to _includes/glossary-header.html index 12ad34335e..61ad5b35e9 100644 --- a/_includes/glossary-header.txt +++ b/_includes/glossary-header.html @@ -2,35 +2,27 @@ - {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - + + - - - + + + - - - + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/header.txt b/_includes/header.txt deleted file mode 100644 index ff4295a4b0..0000000000 --- a/_includes/header.txt +++ /dev/null @@ -1,159 +0,0 @@ - - - - {% if page.partof %}{% assign words = page.partof | split: '-' %}{% for word in words %}{{ word | capitalize }} {% endfor %}- {% endif %}{% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/headerbottom.html b/_includes/headerbottom.html new file mode 100644 index 0000000000..d9e11dedea --- /dev/null +++ b/_includes/headerbottom.html @@ -0,0 +1,3 @@ + + + diff --git a/_includes/headertop.html b/_includes/headertop.html new file mode 100644 index 0000000000..bf2150c17b --- /dev/null +++ b/_includes/headertop.html @@ -0,0 +1,25 @@ + + + + {% if page.title %}{{ page.title }} | {% endif %}{{ site.title }} + {% if page.description %} + + {% endif %} + + + + + + + + + + + + + + + + + + diff --git a/_includes/index-header.txt b/_includes/index-header.txt deleted file mode 100644 index 4a2043a74e..0000000000 --- a/_includes/index-header.txt +++ /dev/null @@ -1,264 +0,0 @@ - - - - - {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/inner-page-blog-detail-main-content.html b/_includes/inner-page-blog-detail-main-content.html new file mode 100644 index 0000000000..bf616325b4 --- /dev/null +++ b/_includes/inner-page-blog-detail-main-content.html @@ -0,0 +1,27 @@ +
+
+
+
+
+
+

{{page.date | date: "%A %-d %B %Y"}}

+

{{page.by}}

+
+ {% if page.tags %} +
    + {% for tag in page.tags %} +
  • {{tag}}
  • + {% endfor %} +
+ {% endif %} +
+
{{page.category | upcase}}
+

{{page.title}}

+ {{content}} +
+
+ + {% include sidebar-toc.html %} +
+
+
\ No newline at end of file diff --git a/_includes/inner-page-main-content.html b/_includes/inner-page-main-content.html new file mode 100644 index 0000000000..9587a304cb --- /dev/null +++ b/_includes/inner-page-main-content.html @@ -0,0 +1,12 @@ +
+
+
+
+ {{content}} +
+
+ + + {% include sidebar-toc.html %} +
+
diff --git a/_includes/localized-overview-index.txt b/_includes/localized-overview-index.txt deleted file mode 100644 index c63454870b..0000000000 --- a/_includes/localized-overview-index.txt +++ /dev/null @@ -1,34 +0,0 @@ -{% for enpost in site.categories.core %} -{% for post in site.pages %} -{% if post.overview and post.overview == enpost.overview and post.language == page.language %} - -{% if post.partof %} -* {{ post.title }} {{ post.label-text }} - {% for pg in site.pages %} - {% if pg.partof == post.partof and pg.outof and pg.language == page.language %} - {% assign totalPages = pg.outof %} - {% endif %} - {% endfor %} - - {% if totalPages %} -
    - {% for i in (1..totalPages) %} - {% for pg in site.pages %} - {% if pg.partof == post.partof and pg.num and pg.num == i and pg.language == page.language %} -
  • {{ pg.title }}
  • - {% endif %} - {% endfor %} - {% endfor %} -
- {% else %} **ERROR**. Couldn't find the total number of pages in this set of tutorial articles. Have you declared the `outof` tag in your YAML front matter? - {% endif %} -{% else %} - {% if post.hidden == true %} - {% else %} -* [{{ post.title }}]({{ site.baseurl }}{{ post.url }}) {{ post.label-text }} - {% endif %} -{% endif %} - -{% endif %} -{% endfor %} -{% endfor %} diff --git a/_includes/masthead-community.html b/_includes/masthead-community.html new file mode 100644 index 0000000000..1d5f4912a7 --- /dev/null +++ b/_includes/masthead-community.html @@ -0,0 +1,37 @@ +
+
+
+
+
+

Discourse

+ Mailing list +
    + {% for forum in site.data.chats-forums.discourseForums %} +
  • + {{forum.title}} +
    +

    {{forum.title}}

    +

    {{forum.subtitle}}

    +
    +
  • + {% endfor %} +
+
+
+

Gitter

+ Real-time (topic-specialized) chat + +
+
+
+
+
\ No newline at end of file diff --git a/_includes/masthead-documentation.html b/_includes/masthead-documentation.html new file mode 100644 index 0000000000..a15b70e81e --- /dev/null +++ b/_includes/masthead-documentation.html @@ -0,0 +1,34 @@ +
+
+
+
+ {% for section in page.sections %} +
+

{{ section.title }}

+ {% for link in section.links %} + +
+ +
{{link.title}}
+
+
+

{{link.description}}

+
+
+ {% endfor %} +
+
  + {% if section.more-resources %} + More Resources: + + {% endif %} +
+ {% endfor %} +
+
+
+
diff --git a/_includes/navbar-inner.html b/_includes/navbar-inner.html new file mode 100644 index 0000000000..eb64eda00d --- /dev/null +++ b/_includes/navbar-inner.html @@ -0,0 +1,67 @@ + +
+
+ + +
+
diff --git a/_includes/online-courses.html b/_includes/online-courses.html new file mode 100644 index 0000000000..73fba6a50c --- /dev/null +++ b/_includes/online-courses.html @@ -0,0 +1,91 @@ + +
+
+

Online Courses

+
+ + {% comment %} + We're going to follow the next ordering for the online courses: + 1- First we'll show those items that belong to an specific specialization (i.e.: Scala's progfun in Coursera). Those will be ordered alphabetically by title and each item under the specialization by the `specialization-order` tag in each one. + 2- After those, courses that don't belong to any specific specialization. + We'll only show those courses that are not finished yet. + {% endcomment %} + + {% assign specializations = '' | split: ',' %} + {% assign courses = '' | split: ',' %} + {% assign upcomingCourses = '' | split: ',' %} + {% capture now %}{{site.time | date: '%s' | plus: 0}}{% endcapture %} + + {% for course in site.online_courses %} + {% unless specializations contains course.specialization %} + {% assign specializations = specializations | push: course.specialization %} + {% endunless %} + + {% capture endDate %}{{course.end-date | date: '%s' | plus: 86400}}{% endcapture %} + {% if now <= endDate %} + {% assign upcomingCourses = upcomingCourses | push: course %} + {% endif %} + {% endfor %} + + {% for specialization in specializations %} + {% assign specCourses = '' | split: ',' %} + + {% for course in upcomingCourses %} + {% if course.specialization %} + {% if course.specialization == specialization %} + {% assign specCourses = specCourses | push: course %} + {% endif %} + + {% assign sortedSpecCourses = specCourses | sort: 'specialization-order' %} + {% endif %} + {% endfor %} + {% for sortedCourse in sortedSpecCourses %} + {% assign courses = courses | push: sortedCourse %} + {% endfor %} + {% endfor %} + + {% for course in upcomingCourses %} + {% unless course.specialization %} + {% assign courses = courses | push: course %} + {% endunless %} + {% endfor %} + + +
+

Visit all the Online Courses courses

+
+
\ No newline at end of file diff --git a/_includes/pager.txt b/_includes/pager.txt index 417efc705a..b4c4be59c2 100644 --- a/_includes/pager.txt +++ b/_includes/pager.txt @@ -1,10 +1,10 @@ diff --git a/_includes/paginator.html b/_includes/paginator.html new file mode 100644 index 0000000000..7212e643f4 --- /dev/null +++ b/_includes/paginator.html @@ -0,0 +1,9 @@ +{% if paginator.total_pages > 1 %} +
    + {% for page in (1..paginator.total_pages) %} +
  • + {{page}} +
  • + {% endfor %} +
+{% endif %} \ No newline at end of file diff --git a/_includes/scastie.html b/_includes/scastie.html new file mode 100644 index 0000000000..fb7a6ec65a --- /dev/null +++ b/_includes/scastie.html @@ -0,0 +1,23 @@ +
+
+
+

Run Scala in your browser

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer commodo neque eget placerat dapibus. Mauris ullamcorper dui eu pellentesque venenatis. Nam non elit vitae dolor posuere eleifend a facilisis diam

+
+
+ +
+
+
+
+ +
+
+ + Run Scala code interactively +
+
+
+
\ No newline at end of file diff --git a/_includes/search-header.txt b/_includes/search-header.txt deleted file mode 100644 index a013e1d165..0000000000 --- a/_includes/search-header.txt +++ /dev/null @@ -1,267 +0,0 @@ - - - - - {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} - {% if page.description %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_includes/sidebar-toc-glossary.html b/_includes/sidebar-toc-glossary.html new file mode 100644 index 0000000000..f75f98ccd1 --- /dev/null +++ b/_includes/sidebar-toc-glossary.html @@ -0,0 +1,10 @@ + diff --git a/_includes/sidebar-toc-multipage-overview.html b/_includes/sidebar-toc-multipage-overview.html new file mode 100644 index 0000000000..f454abc5e6 --- /dev/null +++ b/_includes/sidebar-toc-multipage-overview.html @@ -0,0 +1,51 @@ +
+ +
diff --git a/_includes/sidebar-toc-singlepage-overview.html b/_includes/sidebar-toc-singlepage-overview.html new file mode 100644 index 0000000000..f605a2ae13 --- /dev/null +++ b/_includes/sidebar-toc-singlepage-overview.html @@ -0,0 +1,31 @@ +
+ +
diff --git a/_includes/sidebar-toc-style.html b/_includes/sidebar-toc-style.html new file mode 100644 index 0000000000..eec6ffb078 --- /dev/null +++ b/_includes/sidebar-toc-style.html @@ -0,0 +1,59 @@ +{% if page.includeTOC or layout.includeTOC %} + {% if page.includeTOC != false %} + + + {% for pg in site.posts %} + {% if pg.overview == page.overview and pg.languages %} + {% assign languages = pg.languages %} + {% endif %} + {% endfor %} + + {% for pg in site.pages %} + {% if pg.overview == page.overview and pg.languages %} + {% assign languages = pg.languages %} + {% endif %} + {% endfor %} + + {% if page.language %} + {% capture intermediate %}{{ page.url | remove_first: page.language }}{% endcapture %} + {% capture rootTutorialURL %}{{ intermediate | remove_first: '/' }}{% endcapture %} + {% else %} + {% assign rootTutorialURL = page.url %} + {% endif %} + +
+ +
+ {% endif %} +{% endif %} diff --git a/_includes/sidebar-toc-tour-overview.html b/_includes/sidebar-toc-tour-overview.html new file mode 100644 index 0000000000..7003c49e74 --- /dev/null +++ b/_includes/sidebar-toc-tour-overview.html @@ -0,0 +1,48 @@ +
+ +
diff --git a/_includes/sidebar-toc.html b/_includes/sidebar-toc.html new file mode 100644 index 0000000000..eec6ffb078 --- /dev/null +++ b/_includes/sidebar-toc.html @@ -0,0 +1,59 @@ +{% if page.includeTOC or layout.includeTOC %} + {% if page.includeTOC != false %} + + + {% for pg in site.posts %} + {% if pg.overview == page.overview and pg.languages %} + {% assign languages = pg.languages %} + {% endif %} + {% endfor %} + + {% for pg in site.pages %} + {% if pg.overview == page.overview and pg.languages %} + {% assign languages = pg.languages %} + {% endif %} + {% endfor %} + + {% if page.language %} + {% capture intermediate %}{{ page.url | remove_first: page.language }}{% endcapture %} + {% capture rootTutorialURL %}{{ intermediate | remove_first: '/' }}{% endcapture %} + {% else %} + {% assign rootTutorialURL = page.url %} + {% endif %} + +
+ +
+ {% endif %} +{% endif %} diff --git a/_includes/sips-topbar.txt b/_includes/sips-topbar.txt deleted file mode 100644 index 65400087e2..0000000000 --- a/_includes/sips-topbar.txt +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/_includes/thanks-to.txt b/_includes/thanks-to.txt deleted file mode 100644 index 1c375077b8..0000000000 --- a/_includes/thanks-to.txt +++ /dev/null @@ -1,14 +0,0 @@ -
-

Thank you

It helps many

-
- -This site and the documentation it contains is the result of a tremendous amount of work by a large number of people over time, from the first Scala team members, to today’s newcomers. In an effort to only scratch the surface, we list some of those whose help was invaluable in the realization of this iteration of the Scala Documentation repository. - -