0
のオブジェクト
Iアクティビティを入力してメソッド/関数を呼び出すと、ここで何が欠けているのか分かりません。私のコードは以下の通りです。
def activities
puts " Hi, groupFish friends, you are in Beautiful San Diego Today."
puts "Do you want to check out La Jolla Beach swipe left or check out Coachella swipe right?"
puts "There are 25 things that are happening within 5 miles!"
print ">"
choice = $stdin.gets.chomp
if choice == "left"
beach_bum
elsif choice == "right"
coachella
else
puts "Keep on swiping and be sure use the search hashtag feature to find activities!"
end
end
活動
def beach_bum
puts " Tera and John are here watching the seals, care to join?"
puts " Do you want to meet them? Y or N."
choice= $stdin.gets.chomp
if choice == "Y"
puts "Great, we'll see you at the cove in 15 minutes."
exit(0)
elsif choice == "N"
puts " Keep swiping, there's rock climbing nearby"
else puts " Jamba Juice is having a free smoothie before 2pm, it's 2miles away"
end
end
def coachella
puts " Heck Yeah, you are about to enter one of the biggest concerts of all time"
puts " There are a total of 10,000 party goers today"
end
ありがとうございました。これはうまくいきました。私が仕事をしてくれなかったコーチェッラを入力したとき、私は推測しています。私は一度それを切り替えたそれは働いた!また、私はこの論理を理解しているかどうか分からないが、なぜ秩序が重要か?最初にアクティビティ機能を呼び出すと、その順番で実行されます。 –
Rubyは未来に時間旅行することができないので、注文は重要です。メソッドが定義されていない(たとえ存在していなくても)、Rubyはそれが何であり、何が存在しないのかを知らない何かを実行することになっていますか? –
@JörgW Mittag ThnxJörg、私はこれを私の答えでもっと明確にしました ネイサン、答えを受け入れることができますか?将来コードを公開するときは、{}ボタンを使用してコードを正しくフォーマットしてください – peter