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.
The idea is to multiply (x-low) and (x-high). If x is in range, then it must be greater than or equal to low, i.e., (x-low) >= 0.
ValueRange. of(minValue, maxValue); range. isValidIntValue(x); it returns true if minValue <= x <= MaxValue - i.e. within the range.
if i.between?(1, 10) do thing 1 elsif i.between?(11,20) do thing 2 ...
Use the ===
operator (or its synonym include?
)
if (1..10) === i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With