在Swift中分离函数声明和定义 [英] Separation of function declaration and definition in Swift

查看:113
本文介绍了在Swift中分离函数声明和定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看新的Swift。我来自C,C ++,Objective-C ...我注意到,在swift中不可能(?)来分离声明和函数的定义。这样做的结果是结构和类声明是非常漫长和膨胀的,因此很难通过查看代码来获得类的快速图片。我做错了吗?有什么办法克服这个问题,除了努力使功能小等吗?感谢提前

解决方案

迅速地,声明与实现没有分离。这与大多数其他现代语言(如Python)一样。如果你想快速了解你的班级,你应该使用代码折叠。简单地折叠所有的方法和功能。并展开一个您要修改/处理的方法。


I'm having a look at the new Swift. I come from C, C++, Objective-C... I notice that in swift is not possible (?) to separate the declaration and the definition of functions. The result of this is that structure and class declarations are very long and bloated, and it is therefore difficult to have a "quick picture" of the class by looking at the code. Am I doing something wrong? Is there any approach to overcome this problem, besides trying to make functions small, etc.? Thanks in advance

解决方案

In swift, there is no separation of declaration vs implementation. This works like most other modern languages like Python. If you want to get a quick picture of your class, you should use code folding. Simply fold all your methods and functions. And unfold a method of you want to modify / work on it.

这篇关于在Swift中分离函数声明和定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆