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