Ruby Tutorial – Object Method Parameters Solution

In this post, we will solve Ruby Tutorial – Object Method Parameters HackerRank Solution. This problem (Ruby Tutorial – Object Method Parameters) is a part of HackerRank Ruby series.

Task

A method may take zero or more parameters as input. To demonstrate this, we look at the asserts we use on HackerRank. 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 ab, 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 we have defined for you as a method for this example) on a and passing b and c as arguments.

Hint

a.range?(b, c)

or

return a.range?(b, c)

or

a.range? b, c

or

return a.range? b, c

Solution – Ruby Tutorial – Object Method Parameters

# write your code here
a.range?(b,c)

Note: This problem (Ruby Tutorial – Object Method Parameters) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *