How to print to console using swift playground?

后端 未结 7 575
余生分开走
余生分开走 2020-11-27 03:57

I have been following the Apple Guide for their new language swift, but I don\'t understand why the bar on the right is only showing \"Hello, playground\" and not \"Hello, w

相关标签:
7条回答
  • 2020-11-27 04:24

    You may still have trouble displaying the output in the Assistant Editor. Rather than wrapping the string in println(), simply output the string. For example:

    for index in 1...5 {
        "The number is \(index)"
    }
    

    Will write (5 times) in the playground area. This will allow you to display it in the Assistant Editor (via the little circle on the far right edge).

    However, if you were to println("The number is \(index)") you wouldn't be able to visualize it in the Assistant Editor.

    0 讨论(0)
提交回复
热议问题