Why does my explicit init crash?

The default memberwise initializer does not evaluate variable-initialization expressions when explicit values are passed in. User-written initializers do evaluate them in all cases.

This is a known behavior, which was first discussed during the SE–0242 review thread:

Quote

The core team described the behavior as a bug, however I don’t know of a corresponding bug report issue for it.

• • •

A few more recent threads have mentioned this as well:

Pre-pitch: remove the implicit initialization of Optional variables

What is a ‘variable initialization expression’?

5 Likes