This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Implicit arguments

3 replies
Oleg Zhurakousky
Joined: 2011-10-14,
User offline. Last seen 42 years 45 weeks ago.
This might be a simple question but its puzzling me.I have a method:

def using(target: String)(implicit conditions: ValueCondition* )...

How can I define an implicit argument?

Defining something like below is already illegal: 

implicit val conditions:ValueCondition* = 

Thanks

Oleg

rkuhn
Joined: 2012-02-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Implicit arguments
I’m not an expert wrt. the spec, but intuitively what would it mean? The asterisk usually stands for “supply 0..n arguments here”, whereas for implicits you need exactly one in scope (simplifying intentionally).

Regards,

Roland

Am Montag, 20. Februar 2012 19:33:14 UTC+1 schrieb oleg.zhurakousky:
This might be a simple question but its puzzling me.I have a method:

def using(target: String)(implicit conditions: ValueCondition* )...

How can I define an implicit argument?

Defining something like below is already illegal: 

implicit val conditions:ValueCondition* = 

Thanks

Oleg

Peter 2
Joined: 2011-02-16,
User offline. Last seen 42 years 45 weeks ago.
Re: Implicit arguments

Hi Oleg,

maybe there is no way to define a corresponding implicit value if you
stick with a repeated parameter.
But you could live with the following:

type ValueCondition = Int
implicit val myConditions = Seq.empty[ValueCondition]
def using(target: String)(implicit conditions: Seq[ValueCondition]) {}
using("A")

Peter

Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Implicit arguments
It would be interesting though if there would be a way to ask for all the implicits that are available..

On Monday, February 20, 2012, rkuhn wrote:
I’m not an expert wrt. the spec, but intuitively what would it mean? The asterisk usually stands for “supply 0..n arguments here”, whereas for implicits you need exactly one in scope (simplifying intentionally).

Regards,

Roland

Am Montag, 20. Februar 2012 19:33:14 UTC+1 schrieb oleg.zhurakousky:
This might be a simple question but its puzzling me. I have a method:

def using(target: String)(implicit conditions: ValueCondition* )...

How can I define an implicit argument?

Defining something like below is already illegal: 

implicit val conditions:ValueCondition* = 

Thanks

Oleg

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland