class - Swift : Methods error in struct -
this question has answer here:
i'm studying swift , i'm trying understand difference between classes , struct, understand it, in these 2 points: 1) classes reference types, whereas structures value types. means when pass instance of structure function, return instance function, or assign value of variable refers structure variable, instance copied. in other words, structures exhibit pass-by-value behavior. swift strings, arrays, , dictionaries implemented structures. contrast, class instances passed reference-no copy taken. 2) classes can subclassed add behavior; structures can not.
why these 2 errors? depends on structure ?, because class not give me same error. 
the reason you're getting errors default, properties of value type (i.e. struct) cannot modified within instance methods (e.g. newrad() , plusone() methods).
Comments
Post a Comment