[RUBY] How to make a judgment method to search for an arbitrary character in an array

【Overview】

1. Conclusion </ b>

2. What is the include method </ b>

3. How did you program it? </ B>

  1. Conclusion

Use the include? Method </ b>!


2. What is the include? Method

include? Is a method to determine if the specified element is in the array!


3. How did you program

def array_hello(strs)
  if strs.include?(hello)
    puts "True"
  else
    puts "False"
  end
end

I want to find the character "hello" in the argument of "strs", so It is written as strs.include? (hello)! You can apply it with the argument .include? (Characters in the array you want to find)!

Recommended Posts