- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Fwd: Re: why isn't the correct type inferred?
Mon, 2011-06-06, 21:38
-------- Original-Nachricht -------- Betreff: Re: [scala-user] why isn't the correct type inferred? Datum: Mon, 06 Jun 2011 21:11:02 +0200 Von: HamsterofDeath
that won't compile either. the correct syntax is ugly as not much that i've seen in my life:
implicit def commonSuperTypeEnhancer[Z, A <: Z, B <: Z, C <: Z, D <: Z, E <: Z, F <: Z](t: (A, B, C, D, E, F)) = new {
def commonSuperTypeIterator = t.productIterator.asInstanceOf[Iterator[Z]]
}
test:
println((1,2,3,4,5,6).commonSuperTypeIterator.sum)
the contravariance-t2 is better
Am 06.06.2011 20:58, schrieb Matthew Pocock:
BANLkTinJxsMuUDEWj_sgUp-_SNX32NF3sw [at] mail [dot] gmail [dot] com" type="cite">It won't - I got the arrows the wrong way around :) Anyway, the T2 example from Jason is much better.
M
On 6 June 2011 19:55, HamsterofDeath <h-star [at] gmx [dot] de" rel="nofollow">h-star@gmx.de> wrote:
Am 06.06.2011 19:54, schrieb Matthew Pocock:
> def productIterator[A, B, C, D, E, F, Z < A < B < C < D < E < F](t6:
> Tuple6[A, B, C, D, E, F]): Iterator[Z]
this does not compile.
--
Matthew Pocock mailto: turingatemyhamster [at] gmail [dot] com" target="_blank" rel="nofollow">turingatemyhamster@gmail.com gchat: turingatemyhamster [at] gmail [dot] com" target="_blank" rel="nofollow">turingatemyhamster@gmail.com msn: matthew_pocock [at] yahoo [dot] co [dot] uk" target="_blank" rel="nofollow">matthew_pocock@yahoo.co.uk irc.freenode.net: drdozer (0191) 2566550