Doesn’t the include?? return a boolean value?
http://apidock.com/ruby/Array/include%3F
Can someone explain how a value of 1 is the result in the last statement?
detect
returns the first item in the range for which the block returns TRUE.
Your example:
(1..10).detect{|i| (1..10).include?(i*3)}
=> 1
returns 1 because that is the first item in the range (1…10) that returns TRUE for the expression (1..10).include?(i*3)
.
thanksss