What is the use of open variables over public variables which are stored? [duplicate]What is the 'open' keyword in Swift?What is the difference between String? and String! (two ways of creating an optional variable)?Swift Beta performance: sorting arraysStatic vs class functions/variables in Swift classes?What is the difference between a property and a variable in Swift?Overriding methods in Swift extensionsVariable with getter/setter cannot have initial value, on overridden stored propertyWhy are class stored properties not supported in classes?Omitting class name when using a class var from the same classWhat design patten it is that the class variable has the class itselfCannot override with a stored property 'leadingConstraint' , Overriding non-open var outside of its defining module xcode 10

Reverse dictionary where values are lists

Solving a recurrence relation (poker chips)

How seriously should I take size and weight limits of hand luggage?

Do UK voters know if their MP will be the Speaker of the House?

Is it possible to create a QR code using text?

Avoiding the "not like other girls" trope?

Short story with a alien planet, government officials must wear exploding medallions

Bullying boss launched a smear campaign and made me unemployable

What do you call someone who asks many questions?

How did the Super Star Destroyer Executor get destroyed exactly?

Cursor Replacement for Newbies

Should I cover my bicycle overnight while bikepacking?

How do I deal with an unproductive colleague in a small company?

What exploit Are these user agents trying to use?

iPad being using in wall mount battery swollen

Detention in 1997

Mathematica command that allows it to read my intentions

How dangerous is XSS?

I would say: "You are another teacher", but she is a woman and I am a man

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Arrow those variables!

Expand and Contract

How badly should I try to prevent a user from XSSing themselves?

Venezuelan girlfriend wants to travel the USA to be with me. What is the process?



What is the use of open variables over public variables which are stored? [duplicate]


What is the 'open' keyword in Swift?What is the difference between String? and String! (two ways of creating an optional variable)?Swift Beta performance: sorting arraysStatic vs class functions/variables in Swift classes?What is the difference between a property and a variable in Swift?Overriding methods in Swift extensionsVariable with getter/setter cannot have initial value, on overridden stored propertyWhy are class stored properties not supported in classes?Omitting class name when using a class var from the same classWhat design patten it is that the class variable has the class itselfCannot override with a stored property 'leadingConstraint' , Overriding non-open var outside of its defining module xcode 10













0
















This question already has an answer here:



  • What is the 'open' keyword in Swift?

    6 answers



I have checking out some code and I came across code that is marked as open for a variable and it is a stored property. What kind of use does open have over public in this case? This is some made up code:



open class God 
open var hasSuperPowers = true


class HalfGod: God
override var hasSuperPowers = false



This does not compile: Cannot override with a stored property 'hasSuperPowers'. This is because the variable is stored.



My question is therefore: What difference does it make when marking my stored property either open or public? Can I do something with an open stored property, which I can not do with a public stored property?



I would expect xCode would give me warning that marking hasSuperPowers as open would have no effect and would falsely imply to other people that they can override this variable. Ofcourse, this only applies when someone can confirm me that open or public does not make any difference.



Edit: I got now three people showing me the difference between open and var. Does my question even get read? Again:



What difference does it make when marking my stored property either open or public? Again: STORED PROPERTY










share|improve this question















marked as duplicate by Sh_Khan swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 8 at 22:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    @Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

    – J. Doe
    Mar 8 at 22:45












  • I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

    – Sulthan
    Mar 8 at 23:06











  • @Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

    – J. Doe
    Mar 8 at 23:07






  • 1





    Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

    – Sulthan
    Mar 8 at 23:08











  • @Sulthan Wow yes you are right :/ I feel dumb now

    – J. Doe
    Mar 8 at 23:11















0
















This question already has an answer here:



  • What is the 'open' keyword in Swift?

    6 answers



I have checking out some code and I came across code that is marked as open for a variable and it is a stored property. What kind of use does open have over public in this case? This is some made up code:



open class God 
open var hasSuperPowers = true


class HalfGod: God
override var hasSuperPowers = false



This does not compile: Cannot override with a stored property 'hasSuperPowers'. This is because the variable is stored.



My question is therefore: What difference does it make when marking my stored property either open or public? Can I do something with an open stored property, which I can not do with a public stored property?



I would expect xCode would give me warning that marking hasSuperPowers as open would have no effect and would falsely imply to other people that they can override this variable. Ofcourse, this only applies when someone can confirm me that open or public does not make any difference.



Edit: I got now three people showing me the difference between open and var. Does my question even get read? Again:



What difference does it make when marking my stored property either open or public? Again: STORED PROPERTY










share|improve this question















marked as duplicate by Sh_Khan swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 8 at 22:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    @Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

    – J. Doe
    Mar 8 at 22:45












  • I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

    – Sulthan
    Mar 8 at 23:06











  • @Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

    – J. Doe
    Mar 8 at 23:07






  • 1





    Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

    – Sulthan
    Mar 8 at 23:08











  • @Sulthan Wow yes you are right :/ I feel dumb now

    – J. Doe
    Mar 8 at 23:11













0












0








0









This question already has an answer here:



  • What is the 'open' keyword in Swift?

    6 answers



I have checking out some code and I came across code that is marked as open for a variable and it is a stored property. What kind of use does open have over public in this case? This is some made up code:



open class God 
open var hasSuperPowers = true


class HalfGod: God
override var hasSuperPowers = false



This does not compile: Cannot override with a stored property 'hasSuperPowers'. This is because the variable is stored.



My question is therefore: What difference does it make when marking my stored property either open or public? Can I do something with an open stored property, which I can not do with a public stored property?



I would expect xCode would give me warning that marking hasSuperPowers as open would have no effect and would falsely imply to other people that they can override this variable. Ofcourse, this only applies when someone can confirm me that open or public does not make any difference.



Edit: I got now three people showing me the difference between open and var. Does my question even get read? Again:



What difference does it make when marking my stored property either open or public? Again: STORED PROPERTY










share|improve this question

















This question already has an answer here:



  • What is the 'open' keyword in Swift?

    6 answers



I have checking out some code and I came across code that is marked as open for a variable and it is a stored property. What kind of use does open have over public in this case? This is some made up code:



open class God 
open var hasSuperPowers = true


class HalfGod: God
override var hasSuperPowers = false



This does not compile: Cannot override with a stored property 'hasSuperPowers'. This is because the variable is stored.



My question is therefore: What difference does it make when marking my stored property either open or public? Can I do something with an open stored property, which I can not do with a public stored property?



I would expect xCode would give me warning that marking hasSuperPowers as open would have no effect and would falsely imply to other people that they can override this variable. Ofcourse, this only applies when someone can confirm me that open or public does not make any difference.



Edit: I got now three people showing me the difference between open and var. Does my question even get read? Again:



What difference does it make when marking my stored property either open or public? Again: STORED PROPERTY





This question already has an answer here:



  • What is the 'open' keyword in Swift?

    6 answers







swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 23:02







J. Doe

















asked Mar 8 at 22:40









J. DoeJ. Doe

3,02411438




3,02411438




marked as duplicate by Sh_Khan swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 8 at 22:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Sh_Khan swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 8 at 22:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1





    @Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

    – J. Doe
    Mar 8 at 22:45












  • I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

    – Sulthan
    Mar 8 at 23:06











  • @Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

    – J. Doe
    Mar 8 at 23:07






  • 1





    Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

    – Sulthan
    Mar 8 at 23:08











  • @Sulthan Wow yes you are right :/ I feel dumb now

    – J. Doe
    Mar 8 at 23:11












  • 1





    @Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

    – J. Doe
    Mar 8 at 22:45












  • I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

    – Sulthan
    Mar 8 at 23:06











  • @Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

    – J. Doe
    Mar 8 at 23:07






  • 1





    Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

    – Sulthan
    Mar 8 at 23:08











  • @Sulthan Wow yes you are right :/ I feel dumb now

    – J. Doe
    Mar 8 at 23:11







1




1





@Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

– J. Doe
Mar 8 at 22:45






@Sh_Khan can you point out the sentence that would help me finding the answer to my question in your provided link? I know the difference between open and public.

– J. Doe
Mar 8 at 22:45














I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

– Sulthan
Mar 8 at 23:06





I think I have answered exactly your question. You can override stored property in another module only if it's public. I have shown what does it mean to override a stored property.

– Sulthan
Mar 8 at 23:06













@Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

– J. Doe
Mar 8 at 23:07





@Sulthan 'You can override stored property in another module only if it's public' What? Clearly we can not override stored properties. And only if it is public? I don't understand.

– J. Doe
Mar 8 at 23:07




1




1





Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

– Sulthan
Mar 8 at 23:08





Clearly you can override stored properties. You cannot override them with another stored property. You can override a stored property only with a computed property.

– Sulthan
Mar 8 at 23:08













@Sulthan Wow yes you are right :/ I feel dumb now

– J. Doe
Mar 8 at 23:11





@Sulthan Wow yes you are right :/ I feel dumb now

– J. Doe
Mar 8 at 23:11












2 Answers
2






active

oldest

votes


















1














You can override a property but not with a stored property. When overriding properties, you have to use a computed property, e.g.:



A class with a stored property:



open class God 
open var hasSuperPowers = true



The property can be overriden only with a computed property:



class HalfGod: God 
override var hasSuperPowers: Bool
didSet
print("(oldValue) -> (hasSuperPowers)")





or



class HalfGod: God 
var hasPowers: Bool = false

override var hasSuperPowers: Bool
get
return hasPowers

set
hasPowers = newValue





You can override properties from other modules only if they are open. public properties cannot be overriden from other modules.






share|improve this answer
































    0














    From the link in the comment:



    An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.



    A public class is accessible but not subclassable outside of the defining module. A public class member is accessible but not overridable outside of the defining module.



    What difference does it make when marking my stored property either open or public?



    • If its marked public, then you cannot override the member outside the defining module.

    Can I do something with an open stored property, which I can not do with a public stored property?



    • You can subclass it outside of the defining module.





    share|improve this answer





























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You can override a property but not with a stored property. When overriding properties, you have to use a computed property, e.g.:



      A class with a stored property:



      open class God 
      open var hasSuperPowers = true



      The property can be overriden only with a computed property:



      class HalfGod: God 
      override var hasSuperPowers: Bool
      didSet
      print("(oldValue) -> (hasSuperPowers)")





      or



      class HalfGod: God 
      var hasPowers: Bool = false

      override var hasSuperPowers: Bool
      get
      return hasPowers

      set
      hasPowers = newValue





      You can override properties from other modules only if they are open. public properties cannot be overriden from other modules.






      share|improve this answer





























        1














        You can override a property but not with a stored property. When overriding properties, you have to use a computed property, e.g.:



        A class with a stored property:



        open class God 
        open var hasSuperPowers = true



        The property can be overriden only with a computed property:



        class HalfGod: God 
        override var hasSuperPowers: Bool
        didSet
        print("(oldValue) -> (hasSuperPowers)")





        or



        class HalfGod: God 
        var hasPowers: Bool = false

        override var hasSuperPowers: Bool
        get
        return hasPowers

        set
        hasPowers = newValue





        You can override properties from other modules only if they are open. public properties cannot be overriden from other modules.






        share|improve this answer



























          1












          1








          1







          You can override a property but not with a stored property. When overriding properties, you have to use a computed property, e.g.:



          A class with a stored property:



          open class God 
          open var hasSuperPowers = true



          The property can be overriden only with a computed property:



          class HalfGod: God 
          override var hasSuperPowers: Bool
          didSet
          print("(oldValue) -> (hasSuperPowers)")





          or



          class HalfGod: God 
          var hasPowers: Bool = false

          override var hasSuperPowers: Bool
          get
          return hasPowers

          set
          hasPowers = newValue





          You can override properties from other modules only if they are open. public properties cannot be overriden from other modules.






          share|improve this answer















          You can override a property but not with a stored property. When overriding properties, you have to use a computed property, e.g.:



          A class with a stored property:



          open class God 
          open var hasSuperPowers = true



          The property can be overriden only with a computed property:



          class HalfGod: God 
          override var hasSuperPowers: Bool
          didSet
          print("(oldValue) -> (hasSuperPowers)")





          or



          class HalfGod: God 
          var hasPowers: Bool = false

          override var hasSuperPowers: Bool
          get
          return hasPowers

          set
          hasPowers = newValue





          You can override properties from other modules only if they are open. public properties cannot be overriden from other modules.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 23:07

























          answered Mar 8 at 22:55









          SulthanSulthan

          99.3k16162204




          99.3k16162204























              0














              From the link in the comment:



              An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.



              A public class is accessible but not subclassable outside of the defining module. A public class member is accessible but not overridable outside of the defining module.



              What difference does it make when marking my stored property either open or public?



              • If its marked public, then you cannot override the member outside the defining module.

              Can I do something with an open stored property, which I can not do with a public stored property?



              • You can subclass it outside of the defining module.





              share|improve this answer



























                0














                From the link in the comment:



                An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.



                A public class is accessible but not subclassable outside of the defining module. A public class member is accessible but not overridable outside of the defining module.



                What difference does it make when marking my stored property either open or public?



                • If its marked public, then you cannot override the member outside the defining module.

                Can I do something with an open stored property, which I can not do with a public stored property?



                • You can subclass it outside of the defining module.





                share|improve this answer

























                  0












                  0








                  0







                  From the link in the comment:



                  An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.



                  A public class is accessible but not subclassable outside of the defining module. A public class member is accessible but not overridable outside of the defining module.



                  What difference does it make when marking my stored property either open or public?



                  • If its marked public, then you cannot override the member outside the defining module.

                  Can I do something with an open stored property, which I can not do with a public stored property?



                  • You can subclass it outside of the defining module.





                  share|improve this answer













                  From the link in the comment:



                  An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.



                  A public class is accessible but not subclassable outside of the defining module. A public class member is accessible but not overridable outside of the defining module.



                  What difference does it make when marking my stored property either open or public?



                  • If its marked public, then you cannot override the member outside the defining module.

                  Can I do something with an open stored property, which I can not do with a public stored property?



                  • You can subclass it outside of the defining module.






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 8 at 22:52









                  L0uisL0uis

                  55935




                  55935













                      Popular posts from this blog

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme