我第一次嘗試返回函數。以下幾行代碼顯示沒有輸出。我想弄清楚我的代碼有什麼問題。我會很感激你的意見。從紅寶石新手返回命令
def favourite_drink name
if name == "tea"
return "I love tea too!"
end
if name == "lemonade"
return "Stuff's refreshing, isn't it?"
end
if name == "coffee"
return "Dude, don't have too much of that stuff!"
end
"So what exactly is it that you like? (scratches head)"
end
favourite_drink "tea"
下次請看看可用的格式選項,特別是代碼按鈕('{}')。它有助於使您的代碼更具可讀性:D – Nanne 2012-08-01 06:50:35