I'm looking at the following example from CoffeeScript: Accelerated Development
x = true
showAnswer = (x = x) ->
console.log if x then 'It works!' else 'Nope.'
console.log "showAnswer()", showAnswer()
console.log "showAnswer(true)", showAnswer(true)
console.log "showAnswer(false)", showAnswer(false)
I don't understand why showAnswer(...) undefined shows up for each test.
Nope.
showAnswer() undefined
It works!
showAnswer(true) undefined
Nope.
showAnswer(false) undefined
Please explain the output of each case.
x = trueprior to your function if you want to give it a default value.(x = true) ->is a valid (and I think preferred) method signature.