From 957809b9a5c3ec323b06b8f0273ef8e94755dccf Mon Sep 17 00:00:00 2001 From: Erik Pohl <89852209+ErikPohl444@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:38:59 -0500 Subject: [PATCH] Update regular-expression-patterns.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even the Scala 3 requires curly braces when I run it in Scastie. Is this a problem with Scastie's default build [which uses Scala 3] or with the sample code -- which I just fixed? I'm guessing based on my 0 experience with Scala that use of the imported function causes an inference which requires the curly braces. Kept getting “error: recursive value $t needs type” in Scastie using Scala 3 without this fix. Took it as a learning exercise to find out why. --- _tour/regular-expression-patterns.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_tour/regular-expression-patterns.md b/_tour/regular-expression-patterns.md index 40d12e500..d04fb870b 100644 --- a/_tour/regular-expression-patterns.md +++ b/_tour/regular-expression-patterns.md @@ -34,9 +34,10 @@ import scala.util.matching.Regex val numberPattern: Regex = "[0-9]".r -numberPattern.findFirstMatchIn("awesomepassword") match +numberPattern.findFirstMatchIn("awesomepassword") match { case Some(_) => println("Password OK") case None => println("Password must contain a number") +} ``` {% endtab %}