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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:15:57+00:00 2026-05-29T15:15:57+00:00

Is there a way to overload methods in Scala that take multiple parameter lists?

  • 0

Is there a way to overload methods in Scala that take multiple parameter lists? E.g. I’d like to do this:

def foo(a: Int)(b: Int)(c: Int): Int

def foo(a: Int)(b: Int): Int

I can define it like this, but trying to call the second method like this:

foo(1)(1)

makes the compiler complain about “ambiguous reference to overloaded definition”, which seems justified. Is there a way to achieve something like this? The last parameter might be considered optional in some cases, for example.

  • 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-29T15:15:58+00:00Added an answer on May 29, 2026 at 3:15 pm

    You can’t use overloading for this, since due to the currying there would be two foo methods differing only in their return type.

    You can use Scala 2.8’s optional and named parameters to approximate this, but you’d have to call the method as foo(1)(1)(). E.g.,

    object Hello {
      def foo(a : String = "Hello,") : String = a
    
      def main(args: Array[String]) {
        println(foo() + foo(" world!"))
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are utility methods to create ImmutableMap like Immutable.of(Key, value) and its overload. But
Is there a way to overload the event += and -= operators in C#?
is there way how to get name ov event from Lambda expression like with
Today, a fellow team member checked-in some code that looked like this var query
Possible Duplicate: Operator Overloading in PHP Is there a way to overload the =
Let say I have a class like this: public sealed class Foo { public
Is there a way to overload Django's get_FIELD_display() function properly? When I call the
Is there a way to pass an optional parameter to a webservice, instead of
Is there a way of forcing the C# compiler to ignore missing operator overloads
Is there way in next piece of code to only get the first record?

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.