4 ms·
`copy` alone is not a red flag. There are definitely cases where you need to use it for safety -- mutable pair types like property list types, for example. But
by KerrAvon 2y ago
`copy` alone is not a red flag. There are definitely cases where you need to use it for safety -- mutable pair types like property list types, for example. But you can't trust an object like -- for example -- NSWindow to do something sane with it unless the behavior is explicitly documented.
- ChrisMarshallNY 2y agoWell, most of my work, these days, is in UIKit, so I'm fairly used to "let" not meaning much. I also tend to rewrite the code completion implicit unwraps (!) with explicit ones (?). Forces me to acknowledge that I'm skating on thin ice. If there's something that I need to keep around, I make a local let copy of just that property, as opposed to the whole shooting match that contains it, or I look up the value in a JiT manner. I tend to have a lot of computed properties. I'll often extend base classes and structs, to add computed accessors.
- meindnoch 2y ago>I also tend to rewrite the code completion implicit unwraps (!) with explicit ones (?). Forces me to acknowledge that I'm skating on thin ice. Hold on. Do you prefer your code failing silently instead of crashing?
- ChrisMarshallNY 2y agoNope. I can't use the properties without explicitly unwrapping them. Implicit means that I can pretend they aren't optional. But I often have lines that use ?? to bring in alternatives, and will, if the occasion calls for it, allow the app to fail silently. I tend to like using things like assertions and preconditions, if I want to make the app crash.