Hello everyone, I'm Teddy and just starting to learn Swift 5 with xcode 13.
I thought that by creating a Playground I could make short and simple codes to help my understanding of the language. However I get stuck on the same error message :
Expressions are not allowed at the top level
here is all of my code :
//
// Main.swift
// Swift-Playground
//
import Foundation
func greet(_ person: String, nicely: Bool = true) {
if nicely == true {
print("Welcome \(person) !")
} else {
print("Ooh no, it's \(person) again...")
}
}
greet("teddy")
For the moment my playground only contains an assets and Main file.
What is missing in code to make simple tests ? Thanks.