From e56e7e1e38d3ba1f3703296bdb65d000767fd030 Mon Sep 17 00:00:00 2001 From: arthurwrls Date: Fri, 4 Nov 2022 13:00:25 +0200 Subject: [PATCH] Default parameters in function --- .../Contents.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Codecademy.playground/Pages/Default parameters.xcplaygroundpage/Contents.swift diff --git a/Codecademy.playground/Pages/Default parameters.xcplaygroundpage/Contents.swift b/Codecademy.playground/Pages/Default parameters.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000..4a42073 --- /dev/null +++ b/Codecademy.playground/Pages/Default parameters.xcplaygroundpage/Contents.swift @@ -0,0 +1,13 @@ + +// Use some default parameters in function + +func bookingTicket(passengerName: String = "Arthur", seatClass: String = "Economy", + timeOfDeparture: Int) -> String +{ + return ("\(passengerName), your seat class is \(seatClass), and you will be departing at \(timeOfDeparture).") +} + +print(bookingTicket(timeOfDeparture: 2200)) + +// Let`s change default parameters +print(bookingTicket(seatClass: "Business", timeOfDeparture: 9))