Range Method Between Certain Integers

Ruby

A method may take zero or more parameters as input. Sometimes, we have to check whether a given number a is within the range b and c (where b c, and both inclusive ).

Three variables a, b, and c are already defined. Your task is to write code that checks whether a is within the range of b and c by calling the method range? (which you will have to create) on a and passing b and c as arguments.

Arguments are passed in through STDIN and should be outputted as STDOUT. For this exercise's test purpose, we will mimic STDIN by creating a string that contains 3 values. Don't worry, you don't have to do any conversion, just focus on writing the code needed for the method.

arr = "5 2 6"
a.range?(b, c)   # => true

arr_2 = "1"
a.range?(b, c)   # => false

arr_3 = "1 2"
a.range?(b, c)   # => false
class Integer def range? *data end end
< >