Map requires you to return a value you wish to map the optional to, this is
more like a forEach that only fires when the Optional is .Some

*___________________________________*

*James⎥Head of Trolls*

*[email protected] <[email protected]>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On 23 June 2016 at 16:56, Dmitri Gribenko <[email protected]> wrote:

> On Thu, Jun 23, 2016 at 8:36 AM, James Campbell via swift-evolution
> <[email protected]> wrote:
> > I was wondering if people would be open to adding an unwrap method to the
> > Optional type,  I already have a method like this which shortens code for
> > me.
> >
> > So this:
> >
> > let myReallyLongOptionalName: String? = "Hey"
> >
> > if let string = myReallyLongOptionalName {
> >   doSomethingWith(string)
> > }
> >
> > Could become"
> >
> > let myReallyLongOptionalName: String? = "Hey"
> >
> > myReallyLongOptionalName.unwrap {
> >   doSomethingWith($0)
> > }
>
> We have that, it is called '.map'.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/
>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to