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 8620425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:34:36+00:00 2026-06-12T06:34:36+00:00

How is the following parenthesized? val words = List(foo, bar, baz) val phrase =

  • 0

How is the following “parenthesized”?

val words = List("foo", "bar", "baz")
val phrase = "These are upper case: " + words map { _.toUpperCase } mkString ", "

Is it the same as

val words = List("foo", "bar", "baz")
val phrase = "These are upper case: " + words.map(_.toUpperCase).mkString(", ")

In other words, do implied dots (“.”) and parentheses have the same precedence as the real ones?

Is the first version the same as

val words = List("foo", "bar", "baz")
val phrase =
  "These are upper case: " + (words map { _.toUpperCase } mkString ", ")
  • 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-06-12T06:34:38+00:00Added an answer on June 12, 2026 at 6:34 am

    Operators starting with letters have the lowest precedence. + has low precedence but higher than map or mkString. So

    "These are upper case: " + words map { _.toUpperCase } mkString ", "
    

    should be parsed as:

    (("These are upper case: " + words).map{ _.toUpperCase }).mkString(", ")
    

    Think of it as:

    v1 + v2 map v3 mkString v4
    ((v1 + v2) map v3) mkString v4
    

    See my other answer for more info: When to use parenthesis in Scala infix notation

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

Sidebar

Related Questions

Following code works perfect and adds 1 and 2 values to the list, but
following situation: <body> <div style=position:fixed; width:100%>[place holder for header]</div> <div style=position:relative;width:100%;margin-top:100px>[content]</div> </body> I need
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following are the simple statements in the irb shell. What does nil in the
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();
Following chunk html code works as expected: <iframe src=http://www.amazon.com/></iframe> But when trying embed inner
Following leads in this thread and others, I've set up a code block where
Following is the Play 2 app, https://github.com/playframework/Play20/tree/master/samples/java/forms Which portrays Dynamic form binding where form
Following on from my previous question: Simple inner join in linq How would I

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.