The foreach statement is just syntactic sugar which is expanded into for with an iterator. Therefore, if the iterable is null, the code fails with a NullPointerException.
I think it would be nice to make the loop handle null as an empty container.
Code such as
foreach elt in elements {
workWith(elt)
}
would be expanded in
for (let it=elements?:iterator(), it isnt null and it: hasNext(), ) {
let elt = it: next()
workWith(elt)
}