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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:30:14+00:00 2026-05-30T07:30:14+00:00

Consider the following: def f(implicit a: String, y: Int = 0) = a +

  • 0

Consider the following:

def f(implicit a: String, y: Int = 0) = a + ": " + y
implicit val s = "size"
println(f(y = 2))

The last expression causes the following error:

not enough arguments for method f: (implicit a: String, implicit y:
Int)java.lang.String. Unspecified value parameter a.

However, if you provide a default value to the implicit parameter a, there is no issue:

def f(implicit a: String = "haha!", y: Int = 0) = a + ": " + y
implicit val s = "size"
println(f(y = 2))

But the last line prints

haha!: 2

while I would have expected

size: 2

So the implicit value ‘s’ is not picked up. If you instead don’t provide any parameters to f and just call

println(f)

then the implicit value is picked up and you get

size: 0

Can someone shed some light on what’s going on here?

  • 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-30T07:30:16+00:00Added an answer on May 30, 2026 at 7:30 am

    Try

    println(f(y = 2, a = implicitly))
    

    Once you start specifying parameters, you can’t go back. It’s either the whole list is implicit or none of it is.

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

Sidebar

Related Questions

Consider following object, object A { def setX(x:Int) = { val x1 = x
Consider the following code: object U { def foo(s:String) = true } val boolType
Consider the following: irb(main):001:0> class A irb(main):002:1> def initialize irb(main):003:2> @string = my string
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider the following Scala code: package scala_java object MyScala { def setFunc(func: Int =>
Consider the following Scala code def NOTImplementedIn[T<: AnyRef](t:T):String = throw new Exception(t.getClass.getName+: Input type
consider the following code if insert() return the list itself. def sieve(l): if not
Please consider the following test program (using scala 2.9.0.1) object test { def main(args:Array[String])
Consider the following Scala code: object MainObject { def main(args: Array[String]) { import Integer.{
Consider the following snippet: >>> def foo(port, out, udp=False, ipv6=False, data=''): ... if not

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.