At first, I was told that PrettyQrView was wrong, so I changed PrettyQrView(qrCode: qrData) to PrettyQrView.data(data: qrData), and this error disappeared, but the error in else is still the same. I don’t know if it’s a location issue, but even if I move the location, the error remains the same.
I wanted to fix the error in else and create a code that generates a QR code containing the ID used when the user logs in.
2
Answers
You can’t use if-else inside a collection. The only available control-flow operator that uses the keyword
if
is the collection if, that conditionally includes the element to the list.You might be looking for the conditional operator (known as ternary operator in other languages) instead.
You have to remove the comma, so not
but