Post #1758320
2026-04-20 15:43 UTC
@teilweise @Sarnau @mayo @dasdom
I don't remember which is which, but in one case you can change the value, and in the other you can change it to point to a different string. Neither of which is allowed in Swift. Besides, Swift strings are supposed to be (copy on write) value types, so not comparable to a pointer anyway.
Your comparison fits pretty well for classes, though. Unless you use @ mutating as intended.
My point was that a const is supposed to be treated exactly like a literal (where semantically equivalent), otherwise it still loses out to plain old nasty # define. Swift let is so much more than const, but is supposed to replace const in the simple cases.
(C# goes the other way and adds the "readonly" keyword where a true const is not possible).
Replies (0)
No replies.