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

Fwd: Re: why isn't the correct type inferred?

No replies
H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.


-------- Original-Nachricht -------- Betreff: Re: [scala-user] why isn't the correct type inferred? Datum: Mon, 06 Jun 2011 21:11:02 +0200 Von: HamsterofDeath An: Matthew Pocock

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


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