Member-only story
This Is Stack Overflow’s Most Downvoted Swift Question
Fair or not?

This week, there was one particular question that caught my eye on Stack Overflow. Here it is:

That happens to have a scope of -34, making it the most downvoted question about Swift currently on Stack Overflow.
Let us explore what happened!
The Question
The question has a comment that it represents “standard, well-documented Swift syntax|.” This may well be true. However, it is worth looking at the question and what is being asked here.
struct Physics {
static let smallCoin : UInt32 = 0x1 << 1
static let smallCoin2 : UInt32 = 0x1 << 2
static let ground : UInt32 = 0x1 << 3
}
A struct (which is a value type) and static
have been used, which means that the properties are associated with the type that they are declared on rather than the instance. In this case, there are three properties, all of which are unsigned integers representing different values.
It would be useful to create an instance of this struct and then read out the properties, which is something that can be…