Skip to content

Fix #1485 (en), add : Unit = for the deprecated procedure snippet. #1490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions _overviews/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ the Scala tools without knowing too much about the language. Here is
how it looks:

object HelloWorld {
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ of the corresponding Java packages:
import java.text.DateFormat._

object FrenchDate {
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
val now = new Date
val df = getDateInstance(LONG, Locale.FRANCE)
println(df format now)
Expand Down Expand Up @@ -216,13 +216,13 @@ endlessly prints the sentence "time flies like an arrow" every
second.

object Timer {
def oncePerSecond(callback: () => Unit) {
def oncePerSecond(callback: () => Unit): Unit = {
while (true) { callback(); Thread sleep 1000 }
}
def timeFlies() {
def timeFlies(): Unit = {
println("time flies like an arrow...")
}
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
oncePerSecond(timeFlies)
}
}
Expand All @@ -244,10 +244,10 @@ program using an anonymous function instead of *timeFlies* looks
like that:

object TimerAnonymous {
def oncePerSecond(callback: () => Unit) {
def oncePerSecond(callback: () => Unit): Unit = {
while (true) { callback(); Thread sleep 1000 }
}
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
oncePerSecond(() =>
println("time flies like an arrow..."))
}
Expand Down Expand Up @@ -304,7 +304,7 @@ order to call them, one has to put an empty pair of parenthesis after
their name, as the following example shows:

object ComplexNumbers {
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
val c = new Complex(1.2, 3.4)
println("imaginary part: " + c.im())
}
Expand Down Expand Up @@ -522,7 +522,7 @@ several operations on the expression `(x+x)+(7+y)`: it first computes
its value in the environment `{ x -> 5, y -> 7 }`, then
computes its derivative relative to `x` and then `y`.

def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
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)
Expand Down Expand Up @@ -708,7 +708,7 @@ contained by the cell. For example, to create and use a cell holding
an integer, one could write the following:

object IntegerReference {
def main(args: Array[String]) {
def main(args: Array[String]): Unit = {
val cell = new Reference[Int]
cell.set(13)
println("Reference contains the half of " + (cell.get * 2))
Expand Down