Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update regular-expression-patterns.md #3132

Closed
wants to merge 1 commit into from

Conversation

ErikPohl444
Copy link
Contributor

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.

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.
@gkepka
Copy link
Contributor

gkepka commented Dec 16, 2024

What solves the problem and results in imho a more idiomatic code is to first store the message in a variable and then print it:

val message = numberPattern.findFirstMatchIn("awesomepassword") match
  case Some(_) => "Password OK"
  case None => "Password must contain a number"

println(message)

@adpi2
Copy link
Member

adpi2 commented Dec 16, 2024

Same as #3133

It seems it is a bug in Scastie and we are going to fix it.

@adpi2 adpi2 closed this Dec 16, 2024
@ErikPohl444
Copy link
Contributor Author

Thanks. I copied the more idiomatic snippet to learn from. I appreciate the follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants