gpt4 book ai didi

Swift - 将导入放在文件开头与中间某处是否有任何性能差异?

转载 作者:搜寻专家 更新时间:2023-11-01 06:16:51 24 4
gpt4 key购买 nike

当我将我的代码安排为时,性能会有缺陷吗,

import Foundation

class Foo { }

import SomethingElse

extension Foo: SomethingElse { }

与将所有导入的模块放在文件开头相比?

import Foundation
import SomethingElse

class Foo { }

extension Foo: SomethingElse { }

最佳答案

没关系,请参阅 here

Most Swift files in your app are order-independent, meaning you can use a type before it is defined, and can even import modules at the bottom of the file (although that is not recommended Swift style.)

关于Swift - 将导入放在文件开头与中间某处是否有任何性能差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42903679/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com