【发布时间】:2016-10-04 09:08:03
【问题描述】:
我收到一条错误消息,上面写着 rb:10:in 'activities': undefined local variable or method 'beach_bum' for main:Object
我通过输入活动来调用方法/函数,我不确定我在这里缺少什么?我的代码在下面列出。
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