gpt4 book ai didi

swift - 封装对清除变量或常量的类型有何作用?

转载 作者:可可西里 更新时间:2023-11-01 02:05:25 24 4
gpt4 key购买 nike

我目前正在阅读 Apple 的“Intro to App Development with Swift”学生指南。在第 9 章“类型”的结尾测验中,它会问:

When you're reading code and aren't sure of the type of a variable or constant, what's the quickest way to find out?

答案是:

Rewrite the section of code using different encapsulation.

但是之前没有介绍过封装的概念,所以比较迷茫。在电子书的词汇表中,它指出:

A language mechanism for restricting access to some of the object components and/or a language construct that facilitates the bundling of data with the methods of operating on that data.

谁能解释这与查找变量或常量的类型有何关系?

提前致谢。

最佳答案

The answer is:

Rewrite the section of code using different encapsulation.

这是一个错误的答案。正确答案是"Use Xcode's [Quick Help] inspector."

Can anyone explain how this relates to finding out about the type of a variable or constant?

这里的建议是,如果您重写源代码以将私有(private)变量公开(即改变它的封装方式),则可以更容易地找到相关变量的类型。

关于swift - 封装对清除变量或常量的类型有何作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43188492/

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