jashkenas/coffee-script — Issue #2040: Destructuring and empty return values
Author: jdonnerstag
Created: 2012-01-15 09:08:58+00:00
State: open

Functions like RegExp.exec may return null, if no match was found. Which means that

re = /xxx(.*?)yyy/
[a, b] = re.exec value

fails with a runtime exception, because _req[0] doesn't exist. Instead I have to do

ref = re.exec(value)
if ref?
[a, b] = ref

I'd like to suggest that a = _ref[0] gets replaced with a = _ref[0] if _ref

Thanks for considerung