arrays - 打印变量时出现 lldb_expr 错误

标签 arrays swift enums swift-playground

在下面的代码中,因为我在 Playground 中打印“aMovie.movi​​esGenere”时遇到错误:

struct Movie: Codable {
    enum MovieGenere: String, Codable {
        case horror, skifi, comedy, adventure, animation
    }

    var name : String
    var moviesGenere : [MovieGenere]
    var rating : Int
}

let aMovie = Movie(name: "Up", moviesGenere: [.comedy , .adventure, .animation], rating : 4)

print(aMovie.moviesGenere)

错误:

[__lldb_expr_98.Movie.MovieGenere.comedy, __lldb_expr_98.Movie.MovieGenere.adventure, __lldb_expr_98.Movie.MovieGenere.animation]

最佳答案

不是错误,而是低级调试器以及 Playground 如何打印出您的枚举。如果你把它分解,你会看到:

[
__lldb_expr_98.Movie.MovieGenere.comedy,
__lldb_expr_98.Movie.MovieGenere.adventure,
__lldb_expr_98.Movie.MovieGenere.animation
]

关于arrays - 打印变量时出现 lldb_expr 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48898797/

相关文章:

python - Python 中的枚举 : isInstance error

ruby-on-rails - 动态映射哈希

swift - 如何使用 Swift 在 Cocoa App 中设置 NSView 的颜色?

ios - 如何在另一个实例变量上使用实例变量的属性

ios - 向 GMSMapView 添加手势识别器以获得 .begin/.ended/.change 手势

java - 使用 JPA 存储枚举值

arrays - 如何计算 O(N) 中未排序整数数组的众数?

python - 限制 Python 中数组/列表中输入值的数量

php - fputcsv - 只有一列

java - 带有美元符号和数字 .class 的 java 文件名是什么意思 (name$1.class)?