LoginSignup
0
1

More than 3 years have passed since last update.

if文を用いて出力メソッドを一呼び出し

Posted at

※初心者向け
※アウトプット練習の為

開発環境
rails 5.2.4.1
ruby 2.5.1

問題内容

20時から翌朝7時までにオウムに喋られると問題があるのでその場合は「NG」、
それ以外は「OK」と出力するメソッドを作成します。
オウムが喋る時をture、喋らない時をfalseと入力することにし、時刻も同時に入力します。


呼び出し方:
parrot_trouble(talking, hour)

def  parrot_trouble(talking, hour)
   if (talking  && (hour < 7 || hour > 20))
     puts "NG"
   else
     puts "OK"
   end
end
0
1
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
1