summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNami-Doc <vendethiel@hotmail.fr>2014-03-09 14:35:36 +0100
committerNami-Doc <vendethiel@hotmail.fr>2014-03-09 14:35:36 +0100
commitdd71873b2d6a38c8c5403d15fc3f28f93d1784df (patch)
treefda47940288980e64ff317324706cd6d2c6c077b
parenteb1e32c1442de11692d5136b69e815118423b72f (diff)
parentbd6d3be775fd6be55f92d1d368b303f40618c0e1 (diff)
Merge pull request #547 from rostdotio/master
[scala] Added explanation for colon character
-rw-r--r--scala.html.markdown5
1 files changed, 4 insertions, 1 deletions
diff --git a/scala.html.markdown b/scala.html.markdown
index 5dfaefe0..2666746e 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -104,10 +104,13 @@ val sq = (x:Int) => x * x
sq(10) // Gives you this: res33: Int = 100.
+// The colon explicitly defines the type of a value, in this case a function
+// taking an Int and returning an Int.
+val add10: Int => Int = _ + 10
+
// Scala allows methods and functions to return, or take as parameters, other
// functions or methods.
-val add10: Int => Int = _ + 10 // A function taking an Int and returning an Int
List(1, 2, 3) map add10 // List(11, 12, 13) - add10 is applied to each element
// Anonymous functions can be used instead of named functions: