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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:06:21+00:00 2026-06-19T01:06:21+00:00

Is there a manner to import a specific method signature? def test() { lazy

  • 0

Is there a manner to import a specific method signature?

def test() {
  lazy val log = LoggerFactory.getLogger("AndroidProxy")
  import log.{error, debug, info, trace}

  trace("This is a test")
  trace "This is also"   // <- This line will not compile 
}

Perhaps it’s not possible, but my primary goal is to allow this without adding in a new method. I’ve tried these to no avail

import log.{error => error(_:String)}
import log.{error(x: String) => error(x)}

I suppose the primary challenge is that all of the methods take one argument. I can call no-argument methods without (), and I can create a chain of method calls that omits the .’s e.g. foo getX toString, but I don’t know how to create an arity-1 call automatically

This is a followup to this question.

  • 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-19T01:06:23+00:00Added an answer on June 19, 2026 at 1:06 am

    The issue with the code:

    trace "This is also"   // <- This line will not compile 
    

    is not that you’re somehow importing too many overloaded variants of trace – it’s that you can’t use Scala’s infix notation this way. An expression like:

    e op
    

    is interpreted as a “Postfix Operation” (see section 6.12.2 of the Scala Language Specification), equivalent to the call:

    e.op
    

    So your code would be equivalent to:

    trace."This is also"
    

    which is of course a compile error.

    If you instead use an “Infix Operation” of the form e1 op e2 (section 6.12.3 of the Scala Language Specification), then there aren’t any problems even if the method is overloaded:

    scala> class Logger { def trace(s: String) = "1arg"; def trace(i: Int, s: String) = "2arg" }
    defined class Logger
    
    scala> val log = new Logger
    log: Logger = Logger@63ecceb3
    
    scala> log trace "This is also"
    res0: String = 1arg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

there is a set of data which is arranged in a specific manner (as
Is there a way to use lapply() in a manner that forces it to
Isn't there another way of using global variables in a Java stlye manner in
Is there a manner in which to catch requests to a class which does
Is there a way to instantiate a new PHP object in a similar manner
I know that TreeSet stores objects in a sorted manner. But is there a
What's the right manner to use NSNotificationCenter? I would know if there is a
I'm adding my first UITableView and it draws in an unexpected manner. There's a
java serializes objects in a well-known and published manner (there's a spec ). what
I want to arrange the nodes in such a manner that there are 2

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.