Skip to content

ahmetbostanciklioglu/Self

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧩 Swift Basics: The self Keyword

A concise, runnable playground showing how self disambiguates properties inside initializers.

Platform iOS Swift Xcode Playground Stars Last Commit

πŸ“– Overview

In Swift, self refers to the current instance of a type. It is most often used inside an initializer or method to distinguish a stored property from a parameter that shares the same name. This repository is a concise, runnable learning example β€” a single Xcode Playground (Self.playground) that demonstrates the pattern with two small struct examples.

πŸ“š What it covers

  • Using self.property = property inside an init to resolve the naming collision between a stored property and an initializer parameter.
  • A minimal struct with one property assigned through a custom initializer.
  • A struct that mixes an injected property with a default-valued property, initializing only the injected one.
  • Watching Swift's Playground evaluate each expression and show its value inline.

πŸš€ Getting Started

git clone https://github.com/ahmetbostanciklioglu/Self.git
cd Self
unzip Self.playground.zip
open Self.playground

Open the playground in Xcode and let it execute β€” the results sidebar shows each expression's value as it runs.

πŸ“‹ Requirements

  • macOS with Xcode 13 or later
  • Swift 5+

πŸ§‘β€πŸ’» Author

Ahmet BostancΔ±klΔ±oğlu β€” @ahmetbostanciklioglu Β· ahmetbostancikli@gmail.com

⭐ If this helped you, consider giving the repo a star!

About

Swift Playground demonstrating the self keyword to disambiguate properties inside struct initializers.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors