You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to compose elements conditionally to avoid too much code duplication.
My code draws a rectangle, and overlays it with some text. I want to be able to use a flag to conditionally control the addition of the Text element based upon e.g. the block size being too small to fit visible text within it. Otherwise I have to move the condition outside and make a choice between returning Rectangle + Text, or just Rectangle.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'd like to be able to compose elements conditionally to avoid too much code duplication.
My code draws a rectangle, and overlays it with some text. I want to be able to use a flag to conditionally control the addition of the Text element based upon e.g. the block size being too small to fit visible text within it. Otherwise I have to move the condition outside and make a choice between returning Rectangle + Text, or just Rectangle.
I've tried something like this, using
.add
to no avail:Beta Was this translation helpful? Give feedback.
All reactions