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
Post a Comment