S
S
Sm4llDev2020-09-05 11:55:30
ruby
Sm4llDev, 2020-09-05 11:55:30

Comparing numbers from ready-made variables and an array consisting of a range?

There are condition variables:

a = [1, 2]
b = [3, 4]
c = [5 ,6]

And the array from the range: There is an extra number - 7 I need to compare the numbers from the variables with an array of numbers and identify matches and mismatches. How to do?

abc = (1..7).to_a

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SsPay, 2020-10-05
@Sm4llDev

a = [1, 2]
b = [3, 4]
c = [5 ,6]

abc = (1..7).to_a

abc.each { |num| (a+b+c).include?(num) ? (puts "#{num} is include in variables") : (puts "#{num} is not include in variables")}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question