在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Ruby/ Ruby小白問題: 三目運算符問題

Ruby小白問題: 三目運算符問題

age = 27
word = "age = #{age}"
if age > 20 ? puts(word) : "no , no"

代碼如上,我想做的事情,很明顯,一個簡單的條件判斷執(zhí)行。
但是運行出現(xiàn)錯誤,

./start.rb:171: syntax error, unexpected end-of-input, expecting keyword_then or ';' or 'n'
0 ? puts(word) : "Oh ,no , no"

怎么解決?加一點說明解釋,更好啦,

回答
編輯回答
礙你眼

if then end 這幾個都要有,只寫if是語法錯誤

2017年10月30日 15:09