[swift-evolution] [Idea] return if / return unless

Christian Kienle christian.kienle at rewe-digital.com
Thu Aug 4 09:31:29 CDT 2016


+1

2016-08-04 15:38 GMT+02:00 Julian Dunskus via swift-evolution <
swift-evolution at swift.org>:

> How often have you written something like the following?
>
> `
> if indexPath.row == 0 { return }
>
> guard let thing = things[index] else { return nil }
> `
>
> I propose adding some syntactic sugar to make such statements more
> readable and simple to write:
>
> `
> return if indexPath.row == 0
>
> return nil unless let thing = things[index]
> `
>
> I don’t know how easy or hard this would be to implement, but I think it
> would improve some code significantly.
>
> –Julian Dunskus
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>


-- 
Mit freundlichen Grüßen

*Christian Kienle*
Mobile Developer

*REWE Digital GmbH*
Domstraße 20, 50668 Köln, Büro: Schanzenstr. 6-20, 51063 Köln
Geschäftsführer: Dr. Jean-Jacques Michel van Oosten (Vorsitzender),
Christoph Eltze, Dr. Johannes Steegmann, Dr. Robert Zores
Handelsregister: Amtsgericht Köln (HRB 78670) UST-ID-Nr.: DE 290 605 450

Telefon: +49 151 11441782
E-Mail: christian.kienle at rewe-digital.com
Internet: *www.rewe-digital.com <http://www.rewe-digital.com/>*

Ein Unternehmen der *REWE GROUP*
http://www.rewe-group.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160804/ac6134b1/attachment.html>


More information about the swift-evolution mailing list