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

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page