Copy on write & Copy on assignment in Swift | Hindi tutorial

Sdílet
Vložit
  • čas přidán 12. 09. 2024

Komentáře • 45

  • @aarukiapniduniya
    @aarukiapniduniya Před 2 lety +2

    Amazing topic to discover.... Great work Ravi ....

    • @CodeCat15
      @CodeCat15  Před 2 lety

      Pretty interesting how such minor details are being taken care of when it comes to memory management, indeed this topic is very interesting and an interviewer favorite question.

  • @jayprakashsharma7
    @jayprakashsharma7 Před 2 lety +1

    You are doing great job sir. I have never seen any youtuber who is doing such a hard word to create quality videos. Thanks a lot for this channel, please keep it alive.

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Thank you for your kind words Jay, I'll try my best to deliver more quality driven video. Thank you once again.

    • @jayprakashsharma7
      @jayprakashsharma7 Před 2 lety +1

      @@CodeCat15 Ab is se jyda bhi quality video ho sakta hai kya 😀

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Koshish kar k dekhta hu, shayad thoda aur improve kar pau khud ko, there’s always room for improvement 😊

  • @narayanrautela5714
    @narayanrautela5714 Před 2 lety +2

    For let and var question, I think we have to change let to var because struct are immutable type so we need to change it.
    Like we use mutating in stuct for modifications.
    Thanks bro for this video 👍

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Excellent explanation Narayan 👍 thank you for your answer

  • @JunaidKhan-ny8tu
    @JunaidKhan-ny8tu Před 2 lety +1

    This is amazing Ravi Bhai ❤❤❤ very concise and to the point 👏

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Thanks Junaid, I am glad this was helpful session.

  • @CodeCat15
    @CodeCat15  Před 2 lety

    Hey there, I hope this video was helpful. The code shown in the video is uploaded on GitHub, given is the link for the same.
    GitHub link: github.com/codecat15/CZcams-tutorial/tree/master/CopyOnWrite
    Here's the discord invite link to iOS Cafe: discord.gg/gB3mhP8DNq

  • @nripendrasingh7472
    @nripendrasingh7472 Před 2 lety +1

    Hi Bro, Amazing explanation, you are providing very valuable knowledge. Keep it up !

    • @CodeCat15
      @CodeCat15  Před 2 lety

      I am glad this was helpful, please feel free to ask questions on the topic and do share the channel with your iOS group

  • @umairahmad4368
    @umairahmad4368 Před 2 lety +1

    Thank you for explaining the COW concept.
    4:09 Answer (As per my understanding)
    "let" is used for constant only, as we are changing/modifying the "car2" property "name", so we need to use "var" there.

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      but the let did work when we were using a class so why did the compiler time error only arise during struct and not class?

    • @umairahmad4368
      @umairahmad4368 Před 2 lety +2

      @@CodeCat15
      Class:-
      with let cause, "class" is considered as "constant of address". It can not be reassigned but can be changed. The property should be with "var" too. Like if we change "var name: String" with "let name: String" then it will not work with the class too.
      Struct:-
      with let cause, it's considered as "constant of value". It is immutable (not modifiable).

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Thank you Umair for this explanation, and well said 👍

    • @umairahmad4368
      @umairahmad4368 Před 2 lety

      @@CodeCat15 Thanks Ravi for counter questions.You always respond to comment section of your video.👍👍💓

  • @arifashraf8342
    @arifashraf8342 Před 2 lety +1

    Great explanation as usual!

    • @CodeCat15
      @CodeCat15  Před 2 lety

      Thank you Arif, am glad it was helpful

  • @dharmendrasinha8806
    @dharmendrasinha8806 Před 2 lety +1

    Amazing explanation 🙏

  • @pavanmanjani7583
    @pavanmanjani7583 Před 2 lety +2

    Hi Nice video
    but I have one query you told reference type doesn't support COW... but in video 9:58 you explained example of COW with class(reference type)

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Good observation Pavan and thank you for asking this question.
      The memory address that you see on the console are of arr1 and arr2 variables which are arrays and arrays are value types not reference types
      The code change at the mentioned time was to prove that the behavior of COW is not dependent on the elements of the array but the array itself.
      Does that answer your question? If not please feel free to ask more questions.

    • @pavanmanjani7583
      @pavanmanjani7583 Před 2 lety +1

      @@CodeCat15 yes got it now
      Thank you for answering
      Keep posting

  • @rahuljamba5846
    @rahuljamba5846 Před rokem +1

    Thats great explanation Ravi, thanks you for sharing your quality knowledge !!

    • @CodeCat15
      @CodeCat15  Před rokem +1

      Glad you liked it! please feel free to ask question on this topic and do share the content with your ios group

    • @rahuljamba5846
      @rahuljamba5846 Před rokem

      @@CodeCat15 sure Ravi I will

  • @mushrankhanpathan
    @mushrankhanpathan Před 2 lety +1

    Amazing knowledge sharing!👍

    • @CodeCat15
      @CodeCat15  Před 2 lety +1

      Glad it was helpful 😊

    • @mushrankhanpathan
      @mushrankhanpathan Před 2 lety

      @@CodeCat15 yes definitely it is, and keep up the good work with quality, all the very best!👍

  • @PropertiesAI
    @PropertiesAI Před 2 lety +1

    thanks much for sharing 🙏🏻

    • @CodeCat15
      @CodeCat15  Před 2 lety

      My pleasure, glad to know this video was helpful 😊 please feel free to ask questions on the topic and do share the video with your iOS group

  • @jayprakashsharma7
    @jayprakashsharma7 Před 2 lety +1

    Class use same memory address that's why they are mutable and value can be modified even we are using let. But in case of struct they share different memory address, it means if you are using let and assigned some value and again you are going to change value it will throw error because you cannot modify value because it share different memory address and it store the previous value also. I think that's why structure are immutable. But in case of class it is mutable because they share same memory address and if we modify the value it means the previous value will be replaced with updated value. It means that the previous value is no longer exist and it behaves like you have not assigned any value earlier. I hope I have explained clearly.

    • @CodeCat15
      @CodeCat15  Před 2 lety +2

      Thanks Jay for providing a detailed answer, good job.

  • @abhishekdhiman9771
    @abhishekdhiman9771 Před 2 lety +2

    Simple and straightforward!
    Thank you for this video.

    • @CodeCat15
      @CodeCat15  Před 2 lety

      Thank you Abhishek 😊 feel free to ask questions on the topic

  • @ranganathchenna4559
    @ranganathchenna4559 Před 2 lety +1

    Good explanation
    but the address after change in object is different in both types ... @9:05

    • @CodeCat15
      @CodeCat15  Před 2 lety

      And that’s what copy on write is, before change both will point to the same address and after the change the object that you changed will point to a different address

  • @naveenkumardugarbbachhrajd9682

    Amazing work .truly very well explanations as well as the mind of teaching skill you have is just FANTASTIC !!! , would request please become the "Hacking with Swift " of INDIA , and maintain the same quality as well as the content >>> only love !!

  • @hafizmuhammadbilal4
    @hafizmuhammadbilal4 Před 2 lety +1

    @code Cat answer: we are making mutable to change value from structure if have calass then no need to do this because class already have refrence type.

  • @prataprana2963
    @prataprana2963 Před 2 lety +1

    I was waited for this.!!
    Thanks Brother for this easy context❤️

    • @CodeCat15
      @CodeCat15  Před 2 lety

      Hope the video answers all your doubts regarding the topic, if not please ask questions in comment or on iOS cafe 😊

  • @emdutt4012
    @emdutt4012 Před rokem

    Beacuse you are changing the name car in car 2 instance but you take variable let in car2which is constant that’s why it is showing error.