我在理解下面的代碼片段中的執行過程中遇到問題。理解可選括號的困難
x = 5
puts (0..10).include?(x) ? "yes" : "no"
它給出所需的輸出是yes
。但是,當我忽略include?
方法的括號內是這樣的:
x = 5
puts (0..10).include? x ? "yes" : "no"
輸出爲false
。 我正在使用ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
你讓我的一天! –