I’ve never coded in Ruby, actually
But I still see a problem here:
def itemsinlist(list, item)
list.each do |x|
if item == x
return true
else
return false
end
end
end
This code will return false every time when first array element is not equals to item
It will not check the rest of array in such case
False should be returned only when loop is finished (the whole array was checked and nothing found):
def itemsinlist(list, item)
list.each do |x|
if item == x
return true
end
return false
end