Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use of unresolved identifier 'println' in swift 3 [duplicate]

Tags:

swift

I'm just a beginner with Swift. I am trying a very basic code, but unable to print things using 'println'. This is my code,

import Cocoa
var myString:String? = nil
if myString != nil {
    println(myString)
}else {
    println("myString has nil value")
}
like image 466
Shreekant Avatar asked Aug 18 '16 05:08

Shreekant


1 Answers

println() does not work in xcode. Instead, print() function is used to print a statement with a newline.

If instead, you were to want to print without a newline, a terminator is used

Try this for your code:

import Cocoa
var myString:String? = nil
if myString != nil {
    print(myString)
} else {
    print("myString has nil value")
}

Example with terminator:

import Cocoa
var myString:String? = nil
if myString != nil {
    print(myString, terminator:"")
} else {
    print("myString has nil value", terminator:"")
}
like image 63
Vaibhav Bajaj Avatar answered Nov 15 '22 16:11

Vaibhav Bajaj