IF
!Ember.isEmpty @get('a') #-> true
AND
!Ember.isEmpty @get('b') #-> false
Then why
!Ember.isEmpty @get('a') and !Ember.isEmpty @get('b') #-> true
Or is it my CoffeeScript?
The issue you're having is with Coffeescript precedence. Your code in javascript is:
!Ember.isEmpty(this.get('a') && !Ember.isEmpty(this.get('b')));
You need to add parens to make the order of operations more explicit here:
!Ember.isEmpty(@get('a')) and !Ember.isEmpty(@get('b'))
So in javascript it is:
!Ember.isEmpty(this.get('a')) && !Ember.isEmpty(this.get('b'));
Everything after .isEmpty
is interpreted as arguments for that function call. If that's not what you want, you need brackets or groups.
Also, you should use not
instead of !
, because of clarity.
If you only use brackets to group calls and their arguments, it becomes clearer:
not Ember.isEmpty(@get 'a') and not Ember.isEmpty @get 'b'
Or even clearer, although a bit lispy
(not Ember.isEmpty @get 'a') and not Ember.isEmpty @get 'b'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With