From 28c9941bc86d9bfb0c4f47dc6a8783e2545d62e8 Mon Sep 17 00:00:00 2001 From: xhudik Date: Sat, 6 Mar 2021 13:37:40 +0100 Subject: [PATCH] added ``` for a code snippet --- _overviews/scala3-book/collections-methods.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_overviews/scala3-book/collections-methods.md b/_overviews/scala3-book/collections-methods.md index 0cc9107b4e..3e6c208a21 100644 --- a/_overviews/scala3-book/collections-methods.md +++ b/_overviews/scala3-book/collections-methods.md @@ -280,9 +280,11 @@ val x :: xs = names Putting that code in the REPL shows that `x` is assigned to the head of the list, and `xs` is assigned to the tail: +```scala scala> val x :: xs = names val x: String = adam val xs: List[String] = List(brandy, chris, david) +``` Pattern matching like this is useful in many situations, such as writing a `sum` method using recursion: