LoginSignup
0
0

More than 3 years have passed since last update.

配列内の任意の文字を探す判定するメソッドの作り方

Posted at

【概要】

1.結論

2.includeメソッドとは何か

3.どのようにプログラムしたか

1.結論

include?メソッドを使う!


2.include?メソッドとは何か

include?は配列の中に指定した要素が、あるかを判定するメソッドです!


3.どのようにプログラムしたか

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

"strs"の引数から"hello"という文字を探したいので、
strs.include?(hello)という書き方にしています!
引数.include?(探したい配列内の文字)で適用できます!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0