3 ms·
For contrived examples this is true but these are a bit contrived. For && vs and, by the time you hit the need to differentiate those in ruby, you'll likely be
by mitchty 13y ago
For contrived examples this is true but these are a bit contrived.
For && vs and, by the time you hit the need to differentiate those in ruby, you'll likely be at the port of operator precedence being a thing that is understandable.
The ternary operator shouldn't even come into play for a beginner in my not so humble opinion ruby/c/c++ or not.
Instead of using the ternary, for ruby i'd be advocating more:
a = if some_truthy_operation/variable
c
else
d
end
Way more verbose sure, but then when they get the hang of that, they can start to learn when the ternary operator is useful, if even. Generally I avoid it.
For the regexp match, I'd rather show them "abc"[/[a-z]{3}/]. That makes a short leap into the === operator and all its varied uses. But to be more close you could also do /[a-z]{3}/.match("abc"), this is admittedly half a dozen of one 6 of the other.
I got nothing for the map bit, but I also know smalltalk so admittedly I'm going to be biased. :)
That said both Python and Ruby have good uses. I'm converting a bunch of my own Ruby stuff to Python for work, and the rest to good old C. So I'm biased, but generally don't give a shit. :D I'd be looking for more information on the background of the person learning and what they want to achieve from programming.
In the end, learning any language, I'll even begrudgingly include PHP in there (just picking on you guys) is a good thing.