3 ms·
Isn't "upto" a loop? The idea, IIRC, is to print the numbers without loops and conditionals.
by ajays 16y ago
Isn't "upto" a loop? The idea, IIRC, is to print the numbers without loops and conditionals.
- 3pt14159 16y ago1.upto(10).class => Enumerator
- jerf 16y agoIt "can be" implemented recursively. If you're going to be pedantic about this (and who doesn't love being pedantic?) you need to be very careful about your definitions, because regardless of what you write you're going to have jump instructions in the finally-executed machine code. If you say that you can't have a loop "anywhere", you're limited to recursion, and then what will you do when someone comes along and points out that recursion and looping are ultimately equivalent? This is one of those cases where examining the boundary too closely makes it dissolve under the scrutiny, and it's better just to smile and nod and play along (and have fun arguing).
- jluxenberg 16y agoputs ((1..1000).to_a.join("\n")) Which, of course, is passing the buck to Range#to_a