Skip to content

ahmetbostanciklioglu/Closures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧩 Swift Basics: Closures

A concise, runnable Swift Playground exploring closures β€” from the simplest block to closures as function parameters.

Platform Swift Xcode Stars Last Commit

πŸ“– Overview

Closures are self-contained blocks of functionality that can be passed around and used in your Swift code β€” they capture references to constants and variables from the context in which they are defined and behave much like anonymous functions.

This is a small, runnable Swift Playground that demonstrates the core forms of a closure step by step: a bare closure, closures that take parameters, closures that return values, and closures passed into functions as arguments. It is meant as a concise learning reference you can open and run to see each concept print its result.

✨ What it covers

  • Simple closures β€” defining and immediately calling a closure with no parameters.
  • Parameterized closures β€” closures that accept one or more input parameters (String, Int).
  • Returning closures β€” closures with explicit return types, including -> String and -> Bool.
  • Closures as function parameters β€” passing closures into functions using both named and shorthand argument labels.
  • Working with inout β€” using a closure's return value to mutate an inout parameter inside a function.

πŸš€ Getting Started

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

Open Closures.playground in Xcode and run it to watch each closure example execute in the results sidebar.

πŸ“‹ Requirements

  • Xcode (with Swift Playground support)
  • Swift 5
  • iOS playground target

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

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

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

About

A concise, runnable Swift Playground demonstrating Swift closures step by step.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors