summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--scala.html.markdown20
1 files changed, 20 insertions, 0 deletions
diff --git a/scala.html.markdown b/scala.html.markdown
index b22ba15b..8bcb5975 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -92,6 +92,26 @@ s(1)
// Tuples
+(1, 2)
+
+(4, 3, 2)
+
+(1, 2, "three")
+
+(a, 2, "three")
+
+// Why have this?
+val divideInts = (x:Int, y:Int) => (x / y, x % y)
+
+divideInts(10,3) // The function divideInts gives you the result and the remainder
+
+// To access the elements of a tuple, use _._n where n is the 1-based index of the element
+val d = divideInts(10,3)
+
+d._1
+
+d._2
+
// Combinators