Groovy web console

subscribe to the feed Subscribe
to this
site
toBoolean (via #groovywebconsole)
tweet this snippet Tweet
this
script

toBoolean

Published 2 months ago by jaxzin
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def bTrue = true
def bFalse = false

def sTrue = 'true'
def sFalse = 'false'
def sNull = null as String

println 'bTrue is true:'  + (bTrue.toBoolean()  ? 'yes' : 'no')
println 'bFalse is true:' + (bFalse.toBoolean() ? 'yes' : 'no')
println 'sTrue is true:'  + (sTrue.toBoolean()  ? 'yes' : 'no')
println 'sFalse is true:' + (sFalse.toBoolean() ? 'yes' : 'no')
println 'sNull is true:'  + (sNull.toBoolean()  ? 'yes' : 'no')