I need to write a loop that does something like:
if i (1..10)
do thing 1
elsif i (11..20)
do thing 2
elsif i (21..30)
do thing 3
etc...
But so far have gone down the wrong paths in terms of syntax.
I need to write a loop that does something like:
if i (1..10)
do thing 1
elsif i (11..20)
do thing 2
elsif i (21..30)
do thing 3
etc...
But so far have gone down the wrong paths in terms of syntax.
For Strings:
#=>true
Use the
===
operator (or its synonyminclude?
)A more dynamic answer, which can be built in Ruby:
So, in this case, the "ranges" are really just fenced in with nils in order to catch the boundary conditions.