ruby - Calculate insersection from arrays using & operator -
i taking number of array , want calculate insersection arrays using & operator in case after calculate intersection str1 & str in str1 array, str1 empty.
n = gets.strip.to_i str1 = array.new str2 = array.new in 0..n-1 str = gets.strip.split("").map { |s| s.to_s } if < 1 str1 << str #puts str1.kind_of?(array) #puts str.kind_of?(array) else #puts str1 #puts "no" #puts str str1 = str1 & str puts str1 end end puts str1.length
str1 << str appends array str array str1 (so ['a', 'b', 'c', ['d', 'e', 'f']]). want assignment instead:
str1 = str
Comments
Post a Comment