SwiftGGTeam / translation

translation work flow
85 stars 13 forks source link

Declare the object of the class as a constant, assign a value to its attribute, a compilation error will occur #311

Closed wangchunping2011 closed 4 years ago

wangchunping2011 commented 4 years ago

title: Declare the object of the class as a constant, assign a value to its attribute, a compilation error will occur date: 29 July tags: categories: permalink:


原文链接=https://swiftgg.gitbook.io/swift/swift-jiao-cheng/09_structures_and_classes 作者= 原文日期=2019年12月 译者=tbchen, Jie Liang, Licardo 校对= 定稿=

在“类和结构体”一章“类是引用类型”一节中,原文写到“声明了一个名为 tenEighty 的常量,并让其引用一个 VideoMode 类的新实例。它的视频模式(video mode)被赋值为之前创建的 HD 分辨率(1920*1080)的一个拷贝。然后将它设置为隔行视频,名字设为 “1080i”,并将帧率设置为 25.0 帧每秒。”,我使用代码(Swift 5)验证了下,如果声明为常量(使用let关键字),会报编译错误--“Cannot assign to property: 'tenEighty' is a 'let' constant”,改用 var修饰就不报错了。