You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are essentially 5 ways to "initialize" a list
(let (results)
(--each ... (push x results)))
(let ((results))
(--each ... (push x results)))
(let ((results nil))
(--each ... (push x results)))
(let ((results ()))
(--each ... (push x results)))
(let ((results '()))
(--each ... (push x results)))
Personally I use 2 and 3 and prefer 2 if there are multiple bindings at the same time
(let ((x 1)
(y 2)
(results)
(z 3))
(--each ... (push x results)))
Having it wrapped in the parens sort of signifies to me it's a list. A nil there wouldn't hurt though, I'm just lazy.
I was hoping there would be some way to distinguish () and nil for example for the purpose of analysis but they both appear as nil to the reader, so meh.
The text was updated successfully, but these errors were encountered:
I generally go with option 2, as then it's easy to add more non-empty elements to the bindings, but I agree that 3 & 4 definitely read better. I'm fine with suggesting the use of nil, although I don't think we should discourage ().
I think the 4th one is better. The 2th in this case: results's initial value will not been care about. The 3th in this case: results is a variable, a object, a interger etc. But not a list, despite nil == (). The 4th one in such case: results is a list.
There are essentially 5 ways to "initialize" a list
Personally I use 2 and 3 and prefer 2 if there are multiple bindings at the same time
Having it wrapped in the parens sort of signifies to me it's a list. A nil there wouldn't hurt though, I'm just lazy.
I was hoping there would be some way to distinguish
()
andnil
for example for the purpose of analysis but they both appear asnil
to the reader, so meh.The text was updated successfully, but these errors were encountered: