Рет қаралды 1,246
See Pawel's full presentation from Swift Heroes, 7-8 April, hosted in Turin and also broadcast globally.
Swift is a language where a lot of magic happens to make the user life easier. But magic is a fickle thing - in one place it lifts your code up, in another it can bring it crashing down. In this talk we will take a look at a few code samples that at first glance should work differently or even don't work at all, but in reality have a well defined, if not a little unexpected, behaviour.
Swift helps the developer quite a lot and has many quality of life features that can be leveraged. But sometimes these can bite us in quite unexpected ways.
I'd like to talk about 4 such cases in Swift here :
- the @autoclosure annotation and a "hidden" retain cycle you can get there
- overriding a method with default value
- how to turn a Swift struct into an NSObject
- and how to have multiple variables of the same name, but different type, in a single object (kind of)
#SwiftHeroes22
Subscribe: / swiftheroes
Tweet: @swiftheroes_it
Connect: / swift-heroes
Read: telegram.me/swiftheroes