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
Let's say I want to get the first item in an array, but i want to make sure that the array is empty first. you can do it in these two ways
if(isNonEmpty(arr)){constfirst=arr[0];}
or
if(!isNonEmpty(arr)){return;}constfirst=arr[0];
I would normally prefer the second option as it would allow for less nesting.
The problem is that !isNonEmpty(arr) doesn't really look good and is kinda weird to read (not is not empty). Here it would be much easier to just use isEmpty(arr). This would also read nicely if you want to use !isEmpty(arr) and still feels intuitive.
The text was updated successfully, but these errors were encountered:
Let's say I want to get the first item in an array, but i want to make sure that the array is empty first. you can do it in these two ways
or
I would normally prefer the second option as it would allow for less nesting.
The problem is that
!isNonEmpty(arr)
doesn't really look good and is kinda weird to read (not is not empty). Here it would be much easier to just useisEmpty(arr)
. This would also read nicely if you want to use!isEmpty(arr)
and still feels intuitive.The text was updated successfully, but these errors were encountered: