How can do a tuple comparison in coffeescript similar to that in python? -


this function

st3 = (x, y) ->   console.log "#{x?}, #{y?}"   if [x?, y?] [true, true]   # <- line     'good'   'bad' 

this output

true, true bad 

i want able tuple comparison in python.

in python, if can written as

 if (x, y) == (true, false):    return 'good' 

the coffescript if loop translated javascript such

if ([x != null, y != null] === [true, true]) {   'good'; } 

that's why not evaluated true.

is there alternative way express in coffeescript?

if want check see if of arguments not none, this:

def check_all(*args):     return all(arg not none arg in args) 

if wanted check if they're true (like literally true) use

def check_all(*args):     return all(arg true arg in args) 

if wanted take in list (instead of variable number of parameters, remove asterisk.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -