Reputation: 9140
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
Upvotes: 13
Views: 8965
Reputation: 12383
Also, If you are calling the method before its implementation, the Swift Playground wouldn't allow you to do that, and errors out as below
Use of unresolved identifier 'hello'
WRONG ORDER:
hello()
func hello()
{
print("Hello, World")
}
RIGHT ORDER
func hello()
{
print("Hello, World")
}
hello()
Upvotes: 1
Reputation: 10961
Because you didn't call the function. Just call it:
func hello()
{
print("Hello, World")
}
hello()
Upvotes: 30