I'm currently trying to see if an array of records shares elements with another array.
I'm using the splat operator for a conditional like this:
if @user.tags.include?(*current_tags)
# code
end
This works when tags are present, but returns this error when current_tags are empty.
wrong number of arguments (given 0, expected 1)
This happens a lot in my app so I was wondering if there are any alternatives to achieving this same functionality but in other way that won't blow up if current_tags is an empty array.
include?herecurrent_tagsis empty – should the conditional evaluate or skip the code block in that case?