Groovy web console

subscribe to the feed Subscribe
to this
toString vs as String (via #groovywebconsole)
tweet this snippet Tweet

toString vs as String

Published 1 year ago by Anonymous with tags toString as String
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def a = 123

String b = a.toString()
String c = a as String
println b
println c

def d = null
String e = d.toString()
String f = d as String
println e
println f

assert b == "123"
assert c == "123"
assert e == "null"
assert f == null