Skip to content

Instantly share code, notes, and snippets.

@arosenb2
Created June 6, 2016 17:41
Show Gist options
  • Save arosenb2/3dbbe7d7da9e131177dd326328ae6682 to your computer and use it in GitHub Desktop.
Save arosenb2/3dbbe7d7da9e131177dd326328ae6682 to your computer and use it in GitHub Desktop.
Proving [0] is actually safer than .first() on lists
def list = [].toList()
println "List: $list" // []
println "[0]: ${list[0]}" // Null
println ".first(): ${list.first()}" // Throws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment