Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:52:27+00:00 2026-05-31T19:52:27+00:00

I follow the C family (PHP is a wannabe!) requirement that a statement that

  • 0

I follow the C family (PHP is a wannabe!) requirement that a statement that spans over multiple lines must be enclosed in curlies.

Scala avoids parse errors in this code from O’Reilly’s Programming Scala.

def apply(specification: String): Option[Widget] = specification match {
    case ButtonExtractorRE(label)   => new Some(new Button(label))
    case TextFieldExtractorRE(text) => new Some(new TextField(text))
    case _ => None
  }

whereas I believe it should look like (the body of the function is enclosed):

def apply(specification: String): Option[Widget] = {
    specification match {
            case ButtonExtractorRE(label)   => new Some(new Button(label))
            case TextFieldExtractorRE(text) => new Some(new TextField(text))
            case _ => None
            }
    }

while Scala can parse it, can a programmer “get it”? I dont. Am I missing some intuitive idea?

Should I rather avoid such a practice, if it leads to practical problems (like poor readability?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:52:28+00:00Added an answer on May 31, 2026 at 7:52 pm

    In Scala much more things (including if, match and for with yield) return a result as in other languages. And more data structures are immutable, which often leads to transformation chains of map, filter, flatMap, collect etc – which also gives just one result. Last but not least Scala has excellent support for tuples, which means that you often get back a tuple as a single result where other languages have to sort out single values.

    So in general Scala doesn’t deal as much with variables storing intermediate values as other languages do. That means a function is often just an equation f(a) = b, where b might be quite complex, but is still one chain returning a single result. So it is just naturally to adopt that syntax, which makes immediately clear that you are not juggling with intermediate results, but that you follow a more functional style.

    It should be mentioned that functional languages (except the “lispy” family with a quite different syntax) have similar conventions. So if you look at Haskell, F# or Erlang, you usually won’t see any “blocks” for methods. There are structures like let, case and (for Haskell) do which might look a little bit like blocks, but are expressions as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a family of maths algorithms that all should follow same
Follow up to this question for Facebook Friends.getAppUsers using Graph API that pulls friends
Hello i have this Gmap v3 code that shown the multiple markers (20 markers)
So I've defined a column family that uses composite ids for the row keys.
There is a family of methods ( birddog, shadow, and follow )in the Twitter
Hi stackoverflow family. It is doubtless that unit testing is of great importance in
is there any error in the follow code ? @font-face { font-family: 'raveFire'; src:
follow up: while I had already been using swfobject with static publishing, dynamic publishing
Follow up to this question . I have the following code: string[] names =
Follow up question from Multi-core usage, threads, thread-pools . Are threads moved from one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.