[Ruby] Don't need help but still have a question. Why are FizzBuzz solutions always so unnecessarily big/complex, when you could do something simple, and short like my example?

This is a common mistake I see many beginner programmers

I see your point, but just to be clear, I'm not new to programming, just Ruby.

Both your version and the if/else-if version, are expressing the exact same logic, but the if/else-if version makes it more clear.

Maybe this is just me, and I need to accept things the way they are, but as I've said to others - I find that ternary operators are so 101, and drilled into you so early on regardless of the language your learning, that people getting all confused over a short nested ternary statement is kind of promoting lazy programming. There is a reason ternaries are used, and introduced early on in the learning process, almost regardless of where you are learning, and I don't understand why people are so revolted by them. Again, I'm not talking about massive nested chains by any means, nothing more elaborate than my examples above.

Coders are used to scanning down (moving their eyes in a vertical motion), and your version forces horizontal movement, breaking that rule.

I've never understood that to be a rule, but if it is, duly noted I suppose. Again I cannot stress enough I'm not arguing ternary operators completely replace if/else statements. With that said, just take a look at the heavily praised Doom source code, and that rule seems to go out the window.

Furthermore, the reader has to remember how nested ternaries work + remember in which order to unpack each statement, which distracts them from reading the actual underlying logic.

See again, this touches on my point of promoting lazy coding practices. IMO there is no reason for any programmer to not understand how nested ternaries work, again it's so 101 that I personally find it crazy to not remember. Why do we bother teaching them any more if that's the case? Why do languages keep including them? Maybe I'm getting too philosophical in my questioning.

And to make it worse, the rules will differ from language to language -- for example, ternary operators have right-associativity in Ruby, but have left-associativity in PHP. How exactly you go about interpreting nested ternary expressions is not universal between languages (which is unfortunate, but a fact of life).

I know, as stated I am not a new programmer by any means- just new to Ruby. This is the same for many methods/operators in most languages, so I don't see why ternary operators are some special exception here. Using PHP as an example, how come people don't get confused over things like strong typing in Ruby? That's a pretty big difference, but people seem to get along just fine.

As a result, the nested ternary expression, unless carefully indented and parenthesized (and if you're going to do that, why not just use the if/else-if version?), is likely to add more cognitive load to the reader, meaning that it is more complex and therefore less readable then the if/else-if version.

Well I guess I just need to re-evaluate my approach to conditional statements then, cause obviously consensus wins :/

/r/learnprogramming Thread Parent