Why? This question is going to be very difficult to answer. Clearly the error message could use improvement, as you have noted based on the fact that the IN
operator accepts Set<Id>
.
Likely this omission is just an oversight by the development team. They probably found it an unlikely use case that someone would use an Iterable<Id>
where List<Id>
and Set<Id>
and even List<SObject>
are available for use. In the abstract, use of Iterable<Id>
here seems over-engineered. If you really want support for use of Iterable<Id>
, you should create an Idea and wait a few years for it to gather dust.
If you're committed to using Iterable<Id>
in your method signature, you can build the list yourself by iterating through it.
public List<User> getUsersByIds(Iterable<Id> userIds)
{
List<Id> ids = new List<Id>();
Iterator<Id> i = userIds.iterator();
while (i.hasNext()) ids.add(i.next());
return [SELECT Username FROM User WHERE Id IN :ids];
}
Iterable
at all? – Adrian Larson♦ Aug 25 '16 at 15:35