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

What does encapsulation do for clearing up the type of a variable or constant?

我目前正在通读 Apple 的 "Intro to App Development with Swift" 学生指南。在第 9 章的结尾测验 "Types",它问:

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?

这里的建议是,如果你重写源代码来创建一个私有变量public(即改变它的封装方式),这样会更容易找到有问题的变量的类型。