Swift - Write program to use the nil coalescing operator

Requirements

Rewrite the following code snippet using the nil coalescing operator:

var userInput = "5"
var num = userInput.toInt ()
var value:Int
if num == nil {
    value = 0
} else {
    value = num !
}

Demo

Pre:
 var userInput = "5"
 var num = userInput.toInt ()
 var value = num ?? 0