Xcode 游乐场不执行功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33378542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:07:54  来源:igfitidea点击:

Xcode playground not executing functions

iosxcodeswift-playground

提问by user2924482

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")
}

enter image description here

在此处输入图片说明

Any of you knows why the function is not been call ?

你们中的任何人都知道为什么没有调用该函数?

I'll really appreciate your help

我会非常感谢你的帮助

回答by Arsen

Because you didn't call the function. Just call it:

因为你没有调用函数。就叫它:

func hello()
{
    print("Hello, World")
}

hello()