&& is a logical/boolean "AND". The fact that these work in your example is due to how Ruby deals with truthy/falsy values – you can read the details here: https://www.rubyguides.com/2019/02/ruby-booleans/.
To hopefully answer your questions: I would go with an SQL inclusion operation somewhat like this:
relation = User.where(name: ["James", "Robert", "William"])
# If you really just are looking for the IDs, you can use this the following.
# Note that the order of the IDs isn't the same as the input parameters,
# so if you receive back 1, 5, 10, that doesn't mean that James = 1,
# Robert = 5 and William = 10. If you need a certain order, you need to
# add an `order` clause.
puts relation.ids
# If you want to do more with the result than just have its IDs, you can
# iterate over it like so:
relation.each do |user|
puts "#{user.name}: #{user.id}"
end
User.where(name: ['James'. 'Robert', 'William']).ids. ids%PATH%environment variable has been modified to include the installation directory of Ruby.