I created a new playground and I add simple function but the function is never been call:
var str = "New playground"
func hello()
{
print("Hello, World")
}
Any of you knows why the function is not been call ?
I'll really appreciate your help
In the Swift Playgrounds app on your Mac, click Run My Code (or use the Touch Bar). If there are instructions on the right side of the screen, they slide down when you click Run My Code, so you can watch your code run in the live view. When you click Stop, the instructions slide back up.
An Xcode project allows you to create real apps that you could eventually upload to the App Store (providing you became an Apple Developer). An Xcode Playground allows you to play with code and test it out.
You can use playgrounds in Xcode to quickly write some Swift code, experiment with new Swift syntax, or work on your Swift algorithms skills. Most of all, playgrounds in Xcode are a great way to learn Swift programming. In this tutorial, you'll learn how to get started with playgrounds in Xcode.
One of the biggest differences between Swift Playgrounds and Xcode Playgrounds is that Swift Playgrounds are much less powerful and are built more as an educational tool. My biggest fear is that as Apple brings Swift Playgrounds to the Mac that they will stop supporting and growing Xcode Playgrounds.
Because you didn't call the function. Just call it:
func hello()
{
print("Hello, World")
}
hello()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With