- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Implicit arguments
Mon, 2012-02-20, 19:33
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
Mon, 2012-02-20, 20:51
#2
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
Tue, 2012-02-21, 01:11
#3
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:
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
Regards,
Roland
Am Montag, 20. Februar 2012 19:33:14 UTC+1 schrieb oleg.zhurakousky: