"any" Keyword and Existential types in Swift

  Рет қаралды 9,136

Swift and Tips

Swift and Tips

Күн бұрын

Пікірлер: 32
@AlexPeresedov
@AlexPeresedov 2 жыл бұрын
It is so rare when a tutorial is made with so readable examples so I can watch it even on my phone. Thank you!
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much ☺️
@tundsdev
@tundsdev 2 жыл бұрын
Great video, love the animations and clear explanation
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much 😄
@ЭдуардЕленский-н8ч
@ЭдуардЕленский-н8ч Жыл бұрын
In WWDC22 on this topic the ppl were saying easy rule: better use some first and if compiler doesn’t like it change to any. I guess in ur examples if Animal doesn’t have Self or associated requirements then u can move to some (so its kinda lightweights the function signature in this case in comparison with generic variant)
@indomitabletr1834
@indomitabletr1834 Жыл бұрын
You really know what is going on at memory, i am appreciated
@Cerezo074
@Cerezo074 5 ай бұрын
Thanks for your explanation, pretty clear sir!!!!
2 жыл бұрын
Great way to explain any keyword Pitt! Great video
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much Jesus! 😊
@FredWhosDead
@FredWhosDead 2 жыл бұрын
Great video Pete!
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much Ed! :D
@filipvabrousek6900
@filipvabrousek6900 2 жыл бұрын
Well explained! Many thanks!
@cil7ea
@cil7ea 2 жыл бұрын
love the explanation!
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much! 😊
@theflyingsolo
@theflyingsolo 2 жыл бұрын
I'm glad I found your channel from LinkedIn! Great content, these higher level concepts are so good to know but might get missed by the algorithm. Everyone boost!
@swiftandtips
@swiftandtips 2 жыл бұрын
Thank you very much!!
@blaze9590
@blaze9590 2 жыл бұрын
i think it's witness table in this case and not vTable
@swiftandtips
@swiftandtips 2 жыл бұрын
What’s that Blaze? 😲
@blaze9590
@blaze9590 2 жыл бұрын
@@swiftandtips witness table is basically what’s used in dynamic lookup of methods/properties for existential types(protocols). Apple engineers talked about it in wwdc 2016 on performance. Vtable on the other hand is what’s used for classes that support inheritance/polymorphism/dynamic dispatch.
@swiftandtips
@swiftandtips 2 жыл бұрын
I didn’t remember talk. Thanks for the explanation!
@salmansiddiqui9522
@salmansiddiqui9522 2 жыл бұрын
Why are we using any if we dont have any performance ? or just to tell compiler that its existential type.
@swiftandtips
@swiftandtips 2 жыл бұрын
Hi Salman, that’s a good question!. This is to make a clear distinction between generic constraints and existential types. I recommend you to check the proposal discussion. I left a link in the description 👍
@markvllar
@markvllar 2 жыл бұрын
So adding the any keyword will not resolve the performance implications that you’ve talked about?
@swiftandtips
@swiftandtips 2 жыл бұрын
Hi Mark, No, it just explicitly mark the usage of an existential type, that’s it. 👍
@swiftandtips
@swiftandtips 2 жыл бұрын
Hi @Hitesh Agarwal, short answer is yes, but also this is to clearly distinguish between opaque types vs existential types.
@andrejkling3886
@andrejkling3886 2 жыл бұрын
Thank you... Can you show more real examples?
@swiftandtips
@swiftandtips 2 жыл бұрын
Hi Andrej, just use it every time you declare a protocol type in your code, cheers!
@KFrench1123
@KFrench1123 11 ай бұрын
Well done! Thank you :)
@byaruhaf
@byaruhaf 2 жыл бұрын
is there a way to trigger the warning in swift 5.6?
@swiftandtips
@swiftandtips 2 жыл бұрын
Hi Franklin, that's a good question! I tried using frontend flags in Xcode (enable-explicit-existential-types) but it doesn't work. I will investigate and let you know if I got something. Cheers!
@ЭдуардЕленский-н8ч
@ЭдуардЕленский-н8ч Жыл бұрын
The easy way I can tell right now is Swiftlint rule
@byaruhaf
@byaruhaf Жыл бұрын
@@ЭдуардЕленский-н8ч Thanks which rule is it?
Opaque types: Masking your concrete types
22:18
Swift and Tips
Рет қаралды 4,5 М.
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 66 МЛН
Шок. Никокадо Авокадо похудел на 110 кг
00:44
БЕЛКА СЬЕЛА КОТЕНКА?#cat
00:13
Лайки Like
Рет қаралды 1,4 МЛН
Man Mocks Wife's Exercise Routine, Faces Embarrassment at Work #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 4,2 МЛН
Rust Powered Polymorphism ⚡️ With Traits
9:55
Code to the Moon
Рет қаралды 99 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 809 М.
Generics in Swift: Protocols with associated types
15:37
Swift and Tips
Рет қаралды 10 М.
Swift. Ключевые слова any и some. Экзистенциальный контейнер.
23:46
Программирование - интерес жизни
Рет қаралды 3,9 М.
№37 - Generics в Swift | Прошел этого босса прошел Swift!
1:47:57
В’ячеслав Білий
Рет қаралды 9 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 649 М.
Swift Generics: The Key to Reusable and Flexible Code
23:47
Swift and Tips
Рет қаралды 7 М.
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 66 МЛН