Why Choose Struct Over Class?

前端 未结 16 2274

Playing around with Swift, coming from a Java background, why would you want to choose a Struct instead of a Class? Seems like they are the same thing, with a Struct offeri

16条回答
  •  迷失自我
    2020-11-22 06:19

    With classes you get inheritance and are passed by reference, structs do not have inheritance and are passed by value.

    There are great WWDC sessions on Swift, this specific question is answered in close detail in one of them. Make sure you watch those, as it will get you up to speed much more quickly then the Language guide or the iBook.

提交回复
热议问题