This is the final episode.
Given the three integers a b c, b or c has a difference of 1 from a And True if the difference between the values of b and c is 2 or more. Other than that, False Let's create a method that outputs.
close_far(1, 2, 10) → True close_far(1, 2, 3) → False close_far(4, 1, 3) → True
Use the abs method to convert the return value to an integer.
abs You can get the absolute value by executing the "abs" method on the target number. In other words, if it is a positive number, it will remain as it is, but if it is a negative number, you can get the numerical value that is made into a positive number by taking the sign.
The actual usage is as follows.
num = 5.abs #=> 5 num = (-5).abs #=> 5
def close_far(a,b,c) x = (a-b).abs y = (a-c).abs z = (b-c).abs if x == 1 && z >= 2 puts "True" elsif y == 1 && z >= 2 puts "True" else puts "False" end end