
How to Replace an Else-If Sequence with an Elegant Ternary Operator - osopanda
https://www.fluentcpp.com/2018/02/27/replace-else-if-ternary-operator/
======
eesmith
What that ... there was no need for a gratuitous picture of a woman to clarify
what "cute" means.

Google Image search shows that it's a stock photograph, also used at
[http://orangenaturals.com/blog/teaching-positive-self-
image/](http://orangenaturals.com/blog/teaching-positive-self-image/) ("Marci
Warhaft is teaching young people how to love themselves"),
[http://www.inspiredlivingaffirmations.com/beauty-is-when-
you...](http://www.inspiredlivingaffirmations.com/beauty-is-when-you-can-
appreciate-yourself-when-you-love-yourself-thats-when-youre-most-beautiful/)
("6 Ways To Feel Good About Your Body"), , [http://horoscopean.com/heres-deal-
heartbreak-based-zodiac-si...](http://horoscopean.com/heres-deal-heartbreak-
based-zodiac-sign/) ("Here’s How You Deal With Heartbreak, Based On Your
Zodiac Sign"), [https://childrenandmediaman.com/2016/08/03/tween-girls-
perce...](https://childrenandmediaman.com/2016/08/03/tween-girls-perceptions-
of-the-just-right-body-ideal-and-what-it-means-for-them-socially/) ("Tween
girls’ perceptions of the “just-right” body ideal and what it means for them
socially"), and more.

That last link uses the photograph to illustrate the social pressure,
including from media, for tween girls to look a certain way. In that context,
its use now for a programming blog gives an example of how that social
pressure may manifest itself.

As to the topic at hand, the code I would prefer is:

    
    
      static inline char get_display_char(int x, int y)
      {
        if (x + y >= 30) return '.';
        if (x + y >= 25) return '/';
        if (x + y >= 20) return 'o';
        if (x - 3*y > 0) return '|';
        if (x - y > 0)   return '\\';
        return '_';
      }
       ...
      for (int y = 0; y < 20; ++y)
      {
        for (int x = 0; x < 20; ++x)
        {
          std::cout << get_display_char(x, y);
        }
        std::cout << '\n';
      }

------
Piskvorrr
Clever. (In code, that's _not_ a compliment, it's the opposite of "readable":
no value is added, yet the code's intent is obscured)

