Last active
August 29, 2015 14:04
-
-
Save taiansu/d88d15ad2e1b04573f4d to your computer and use it in GitHub Desktop.
Explaination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# puts something 等同於 puts something.to_s 所以都會自動轉字串 | |
# p something 等同於 puts something.inspect 會印出比較詳細的資料,通常是 debug 用。 | |
# 當你在 | |
def method | |
"aaa" | |
end | |
# 等同於 | |
def method | |
return "aaa" | |
end | |
# 第四題 | |
def scream(words) | |
words = words + "!!!!" | |
return # 這裡等同於 return nil,所以回傳一個空值 | |
#因為已經 return 了,從此以下永遠不會執行到。所以也不會有錯。 | |
puts words | |
end | |
# 最 ruby 的正確寫法是 | |
def scream(words) | |
puts "#{words}!!!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment