Aside: the reason this works is that a PartialFunction extends
Function1, and not the other way around. There are pros and cons to
this; the convenient syntax Kevin showed is one of the big pros.
On 06/16/2016 01:14 PM, Kevin Wright wrote:
> It means:
>
> val list = 1 to 10
> val list2 = list map {
> case 2 | 4 | 6 => i / 2
> case 3 | 9 => i / 3
> case _ => i
> }
>
>
>
> On 16 June 2016 at 17:55, Oliver Ruebenacker <
cur...@gmail.com
> <mailto:
cur...@gmail.com>> wrote:
>
>
> Hello,
>
> I have something a bit like this:
>
> val list = 1 to 10
> val list2 = list.map(i => i match {
> case 2 | 4 | 6 => i / 2
> case 3 | 9 => i / 3
> case _ => i
> })
>
> IntelliJ says I should "Convert match statement to pattern
> matching anonymous function". How would I do that? Thanks!
>
> Best, Oliver
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> <
http://www.type2diabetesgenetics.org/>, Broad Institute
> <
http://www.broadinstitute.org/>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "scala-user" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
scala-user+...@googlegroups.com
> <mailto:
scala-user+...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.
--