Skip to content

Instantly share code, notes, and snippets.

@fossil12
Last active August 29, 2015 14:22
Show Gist options
  • Save fossil12/0a7620864b7c0f29bd55 to your computer and use it in GitHub Desktop.
Save fossil12/0a7620864b7c0f29bd55 to your computer and use it in GitHub Desktop.
Bug or error?
struct StructWithArray {
var arrayInStruct: [Int]
init() {
arrayInStruct = [Int]()
}
}
var structs = [StructWithArray()]
// playground crashes when using this line
structs[0].arrayInStruct.append(3)
// this works just fine
let count = structs[0].arrayInStruct.count
structs[0].arrayInStruct[count] = 3
@fossil12
Copy link
Author

fossil12 commented Jun 4, 2015

I'm not sure. Is this an error on my side or a bug in Swift? My Playground always crashes when using this snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment