In this example val is closure parameter, as such it’s only accessible in the closure scope.
val
Read more here