Do as below to meet your need :
array = [1,1,2,2,3,3]
array.select{|num| [1,3].include? num }
# => [1, 1, 3, 3]
See why you got only [1,1]
.
1 || 3 # => 1
1 || 3
will always returns 1
, thus num == 1
is evaluated as true when select is passing only 1
. As a result you got [1,1]
.