diff --git a/tutorials/tour/anonymous-function-syntax.md b/tutorials/tour/anonymous-function-syntax.md index 2206a7068d..5f99fba246 100644 --- a/tutorials/tour/anonymous-function-syntax.md +++ b/tutorials/tour/anonymous-function-syntax.md @@ -51,3 +51,25 @@ Function1[Int, Int] Function2[Int, Int, String] Function0[String] ``` + +The following example shows how to use anonymous function of the beginning of this page + +```tut +object AnonymousFunction { + + /** + * Method to increment an integer by one. + */ + val plusOne = (x: Int) => x + 1 + + /** + * Main method + * @param args application arguments + */ + def main(args: Array[String]) { + + println(plusOne(0)) // Prints: 1 + + } +} +```