3 ms·
As a rubyist, my main reason for preferring it to Python is what you can do with "blocks". The idiomatic way of iterating over the elements of an array, for ex
by rst 16y ago
As a rubyist, my main reason for preferring it to Python is what you can do with "blocks". The idiomatic way of iterating over the elements of an array, for example, is:
my_array.each do |elt| ... do stuff with elt ...; end
That looks like a control structure, but it's actually invoking a library routine ("each") with a block of code (the part between "do" and "end") as an argument. It's easy to write your own routines which also take blocks as arguments, which effectively adds new control structure to the language.
This flexibility can be really expressive, but it can also easily lead to code that n00bs find confusing. Python syntax isn't as flexible, but that can make Python code more approachable, particularly to novices.
Aside from that, available libraries may make a difference; SciPy and NumPy might come in handy for you, depending on what you're trying to do.