Skip to content
the poor coder

Hackerrank Ruby Tutorial - Object Method Parameters Solution

Poor Man
Published
Updated
Reading time
1 min read

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 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 we have defined for you as a method for this example) on a and passing b and c as arguments.

Hint

Text
a.range?(b, c)

or

Text
return a.range?(b, c)

or

Text
a.range? b, c

or

Text
return a.range? b, c

Solution in ruby#

Python
a.range? b, c

Keep going

2020

Hackerrank Lazy Evaluation Solution

Lazy evaluation is an evaluation strategy that delays the assessment of an expression until its value is needed. Ruby introduced a lazy enumeration feature. Lazy evaluation increases performance by avoiding needless…

ESC