Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coffeescript check if not in array

Tags:

coffeescript

Here's something simple to check if user is in moderator. But I want to check if user is not in moderator.

if err && user in moderators   return 

Intuitively it would be like this

if err && user isnt in moderators   return 

But obviously this doesn't work. What's the best way to do it?

like image 610
Harry Avatar asked Jun 29 '13 00:06

Harry


1 Answers

isnt is the opposite of is, which is the triple equals sign. Just negate the in:

if err and user not in moderators   return 

or, using postfix if:

return if err and user not in moderators 
like image 63
Blender Avatar answered Nov 23 '22 08:11

Blender