|
Re: Implicit type conversion: msg#00503lang.scala
Tony, You can do without transitivity. Example: implicit def AtoB(x: A): B = ... implicit def BtoC(x: B): C = ... In that case you cannot convert from A to C. However, you can plan ahead, by writing: implicit def AtoB(x: A): B = ... implicit def BtoC[B1](x: B1)(implicit toB: B1 => B): C = ... or, equivalently, by giving BtoC a view-bound: implicit def BtoC[B1 <% B](x: B1): C = ... Then A can be converted to C. The conversion that is implicitly inserted is a: A => BtoC(a)(AtoB) Cheers -- Martin On 1/29/07, Tony Morris <tmorris@xxxxxxxxxxx
> wrote: Jon Pretty wrote: |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: assorted beginner questions: 00503, Yang |
|---|---|
| Next by Date: | Re: assorted beginner questions: 00503, Yang |
| Previous by Thread: | Re: Implicit type conversioni: 00503, Tony Morris |
| Next by Thread: | Re: junit and eclipse plugin: 00503, David Pollak |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |