washingcode-book icon indicating copy to clipboard operation
washingcode-book copied to clipboard

Fix the isVisible predicates in Avoid mutation section

Open vkrol opened this issue 5 years ago • 4 comments

This change also makes the isVisible predicates equivalent to the predicates in the previous example in this chapter.

vkrol avatar Aug 20 '19 20:08 vkrol

I should add a comment about this change but it was intentional: the original solution with + is too hacky for me.

sapegin avatar Aug 21 '19 06:08 sapegin

Could you clarify, is this expression is too hacky for you? product1.colors.length + product2.colors.length > 0

vkrol avatar Aug 21 '19 07:08 vkrol

Yep. There's no reason to use summ here ;-/

sapegin avatar Aug 21 '19 07:08 sapegin

Yep. There's no reason to use summ here ;-/

It seems logical to me, but it's up to you, of course. However, the current version contains a closing bracket in the wrong place:

(product1.colors.length > 0 || product2.colors.length) > 0

vs.

(product1.colors.length > 0 || product2.colors.length > 0)

And that was the original reason why I decided to make the PR.

vkrol avatar Aug 21 '19 08:08 vkrol