There is one thing that stopped me from continuing on with Ruby. In fact, it was found in a tutorial...
Code:
def mtdarry
10.times do |num|
square = num * num
return num, square if num > 5
end
end I understand now that it is a conditional return, but to me it would be more logical to use
Code:
if num > 5 return num, square
or whatever that would be. Honestly, I first thought of it as:
Code:
def mtdarry
10.times do |num|
square = num * num
return num, square
if num > 5
end
end Unfortunately, I tried that, and it didn't work since the function definition itself wasn't closed. I know that some languages don't immediately return a value when the line with
return on it is executed, so that's why it made some sense. I ended up sticking with the tiny bit of Python that I know. At least that one seems more logically structured to me! For some people, that logic may work. However, I find it to be more of a nuisance for understanding the program than:
Code:
def mtdarry ():
for num in range(0, 10):
square = num * num
if num > 5: return num, square Cleaner and more logical to me, except for the lack of the iterative for loop such as
for (num = 0; num < 10; num += 1) that is found in C, C++, Java, C#, various dialects of BASIC, etc.
I'm not saying that Ruby is a poor language for programming, of course. I'm simply stating that it didn't appeal to me the way that some other languages do. Because it didn't appeal to me, I warn that it may not appeal to you or some future readers. I choose Python for my own reasons, just as Ruby programmers choose Ruby for their own reasons.