top of page

Private VS Public Parameters.

👋💡🔋Today let’s talk about a basic concept of private and public parameters. They are used to control the access level of properties and methods within a class, struct, or other types. 🟨🟧🟥🟪🟦🟩⬜️





Public Parameters:

✅📍Declaring a parameter as public allows it to be accessed from any source file or module.


✅📍Public parameters are visible and accessible to other modules and files that import the module where the parameter is defined.

✅📍Public parameters are commonly used when you want to expose certain properties or methods to be used by other parts of your code or external modules.


Private Parameters:

✅📍Declaring a parameter as private restricts its access to only within the same source file where it is defined.


✅📍Private parameters are not visible or accessible outside the file, providing encapsulation and hiding implementation details.


✅📍Private parameters are typically used when you want to keep certain properties or methods private to the internal implementation of a type.


By using public and private parameters, you can control the visibility and accessibility of properties and methods, promoting encapsulation, modular design, and code organization. It helps in maintaining code integrity, preventing unintended access, and enabling proper separation of concerns in your Swift codebase.



🚀🚀Let’s build an efficient mobile app that performs well and delivers a great user experience.


>

>

>

>

>


What are your thoughts? comment below.


Follow >> @appsallset for more. Stay Tuned!


>

>

>

>

>


4 views0 comments

Comments


bottom of page