[swift-users] [Feature Request] Extend the `defer` statement

Jun Zhang j.h.z.hang.dev at gmail.com
Sun Oct 8 21:33:45 CDT 2017


Hi dear swift developers,
   I am kind of new to swift and I don't know if this feature already
exists. And if it exists already please tell me how. Thank you very much!
  The feature is to capturing the return value (maybe input value also) of
the function. Here is the demo code:

    func tableView(_ tableView: UITableView, numberOfRowsInSection section:
Int) -> Int {

        defer {

            if $> >= 0 {

                // table is not empty

            }

            else {

                // table is empty

            }

        }

        return dataSource.cout

    }

   I suggest using `$>` as the return value symbol and `$<` as the input
parameter symbol.
   Thank you all and best regards to you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171009/433c1280/attachment.html>


More information about the swift-users mailing list