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

  • Home
  • SEARCH
  • 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 6790041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:40:40+00:00 2026-05-26T17:40:40+00:00

The problem can be found in the following code: def debug[T](format: String, arg1:T, arg2:Any,

  • 0

The problem can be found in the following code:

      def debug[T](format: String, arg1:T, arg2:Any, args:Any*):T = {
        logger.debug(format, (arg1 :: arg2 :: args.toList).toArray)
        arg1
      }

Since what I pass as the second parameter is an array of Any’s, this code should have called SLF4J’s debug method

      public void debug(String format, Object[] argArray);

Yet

      public void debug(String format, Object arg);

ends up being called instead.

Let me give an example.

When I call

    debug("The four parameters are {} as String, {} as Integer, {} as String and {} as Integer.", "1", 2, "3", 4)

It logs

    DEBUG - The four parameters are [1, 2, 3, 4] as String, {} as Integer, {} as String and {} as Integer.

Instead of

    DEBUG - The four parameters are 1 as String, 2 as Integer, 3 as String and 4 as Integer.

NOTE1: I assumed the first call would work based on the scala.Array Scaladoc.

Represents polymorphic arrays. Array[T] is Scala’s representation for Java’s T[].

NOTE2: The code that originated my question can be found at https://github.com/alexmsmartins/UsefullScalaStuff/blob/master/src/main/scala/alexmsmartins/log/LoggerWrapper.scala

This is a small wrapper around slf4j that I use in my Scala projects.

  • 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-26T17:40:41+00:00Added an answer on May 26, 2026 at 5:40 pm

    You are passing an Array[Any], not an Array[Object]. You could try changing your types from Any to AnyRef (in which case you’ll not be able to pass AnyVal‘s such as Int). You could also call .asInstanceOf[Array[AnyRef]] after .toArray, which, in this one particular case, shouldn’t give you trouble because the erasure is the same.

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

Sidebar

Related Questions

I've got a problem I can't find any solution for. I have a textfile
I found the following code in the book Accelerated C++ (Chapter 6.1.1), but I
I've found very strange C# compiler behavior for following code: var p1 = new
The following code (constructed only to demonstrate the problem) compiles and works in Delphi
import org.apache.tools.ant.Project object HelloWorld { def main(args: Array[String]) { println(Hello, world!) } } I
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still
I think that this problem can be sorted using reflection (a technology which I'm
Problem: How can I tell if a selection of text in the CRichEditCtrl has
I have a problem and can't solve it alone. My teacher gives me one
I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions

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.