summaryrefslogtreecommitdiff
path: root/11-top-level-definitions.md
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2013-02-21 03:54:08 +0100
committerIain McGinniss <iainmcgin@gmail.com>2013-02-21 10:08:05 +0000
commit50ce3228b80475d1a0d748ec40ef532afb96df8f (patch)
tree94f28c3aee44315bca931ac12ebdadfa6ba922ef /11-top-level-definitions.md
parent2311e3498bea8d149cc38a6d3585de245134add9 (diff)
downloadscala-50ce3228b80475d1a0d748ec40ef532afb96df8f.tar.gz
scala-50ce3228b80475d1a0d748ec40ef532afb96df8f.tar.bz2
scala-50ce3228b80475d1a0d748ec40ef532afb96df8f.zip
Miscellaneous cleanups:
- Value of Unit is (), not {} - Fix desugared pattern matching code - Mention object-protected values - Use uppercase type variables for Tuple/Function code - Replace Application with App
Diffstat (limited to '11-top-level-definitions.md')
-rw-r--r--11-top-level-definitions.md15
1 files changed, 8 insertions, 7 deletions
diff --git a/11-top-level-definitions.md b/11-top-level-definitions.md
index 02c7db7bb9..fee07fb0fc 100644
--- a/11-top-level-definitions.md
+++ b/11-top-level-definitions.md
@@ -155,8 +155,8 @@ passed to the `main` method as a parameter of type
`Array[String]`.
The `main` method of a program can be directly defined in the
-object, or it can be inherited. The scala library defines a class
-`scala.Application` that defines an empty inherited `main` method.
+object, or it can be inherited. The scala library defines a special class
+`scala.App` whose body acts as a `main` method.
An objects $m$ inheriting from this class is thus a program,
which executes the initializaton code of the object $m$.
@@ -165,12 +165,13 @@ which executes the initializaton code of the object $m$.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package test
- object HelloWord {
- def main(args: Array[String]) { println("hello world") }
+ object HelloWorld {
+ def main(args: Array[String]) { println("Hello World") }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program can be started by the command
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scala test.HelloWorld
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -184,12 +185,12 @@ which executes the initializaton code of the object $m$.
would work as well.
`HelloWorld` can also be defined without a `main` method
- by inheriting from `Application` instead:
+ by inheriting from `App` instead:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package test
- object HelloWord extends Application {
- println("hello world")
+ object HelloWorld extends App {
+ println("Hello World")
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~