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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:13:03+00:00 2026-05-22T17:13:03+00:00

I am learning scala, and meet a little problem. I want to use the

  • 0

I am learning scala, and meet a little problem. I want to use the String method stripMargin as following. But I can not add parenthesis on this method. I remember that no-argument method’s parenthesis is optional, so here why I can not add parenthesis ?

val str=""" hello world
    |" ANd soe"
    |" to world"""

println(str.stripMargin())  // won't compile
println(str.stripMargin)  // compiles successfully
  • 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-22T17:13:04+00:00Added an answer on May 22, 2026 at 5:13 pm

    If the method without parameters in define with (), then writing () is optional. If the method is defined without (), then adding () is not allowed (or, rather, is interpreted as if you were calling apply() on the returned result).

    Good practice recommends that a method without side effects be defined without (), and to keep () both at definition site and call site when it has side effects.

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

Sidebar

Related Questions

I'm learning Scala and trying to use javax.cache in Scala code and can't find
I've recently started learning Scala and was disappointed (but not surprised) that their generics
I am learning Scala now and I want to write some silly little app
OK the question might not say much, but here's the deal: I'm learning scala
I'm learning Scala, so this is probably pretty noob-irific. I want to have a
I'm learning Scala and there is a thing that I can't find out about
I am at a very beginning stage of Scala Learning (I have little understanding
I am learning Scala and I cannot figure out how to translate the following
I'm learning scala and can't find out how to do this: I'm doing a
I'm learning Scala and I want to know the best way of expressing this

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.